-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast: Check if the
#[derive]
attribute is used on a compatible item
gcc/rust/ChangeLog: * ast/rust-ast.h: Create new `Item::Kind` enum and new `Item::get_item_kind` method * ast/rust-item.h: Implement `Item::get_item_kind` method * ast/rust-macro.h: Implement `Item::get_item_kind` method * expand/rust-derive.cc (DeriveVisitor::derive): Check that `#[derive]` is applied on compatible item * expand/rust-expand-visitor.cc: Check if returned item is null before putting it into the item list gcc/testsuite/ChangeLog: * rust/compile/derive_macro9.rs: New test.
- Loading branch information
1 parent
452345f
commit 3c9d66b
Showing
7 changed files
with
125 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#[derive(Clone)] // { dg-error "attribute can only be used on struct, union and enum declaration" } | ||
pub fn foo() {} | ||
|
||
pub struct Struct { | ||
#[derive(Clone)] // { dg-error "attribute can only be used on struct, union and enum declaration" } | ||
a: u32, | ||
} | ||
|
||
pub enum Enum { | ||
// FIXME: This is a bug, it should warn! | ||
#[derive(Clone)] | ||
A, | ||
// FIXME: This is a bug, it should warn! | ||
#[derive(Clone)] | ||
B(u32), | ||
// FIXME: This is a bug, it should warn! | ||
#[derive(Clone)] | ||
C { a: u32 }, | ||
} | ||
|
||
pub union Union { | ||
#[derive(Clone)] // { dg-error "attribute can only be used on struct, union and enum declaration" } | ||
a: u32, | ||
b: u8, | ||
} |