-
Notifications
You must be signed in to change notification settings - Fork 202
fix segfault on macro not found #4333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| macro x( | ||
| $macro_name:ident, | ||
| $macro2_name:ident, | ||
| $type_name:ident, | ||
| $field_name:ident, | ||
| $const_name:ident | ||
| ) { | ||
| pub struct $type_name {} | ||
|
|
||
| pub const $const_name: $type_name = $type_name {}; | ||
|
|
||
| #[x] | ||
| // { dg-error "macro not found" "" { target *-*-* } .-1 } | ||
| macro_rules! $macro_name { | ||
| () => {}; | ||
| } | ||
|
|
||
| pub macro $type_name { | ||
| (Copy $e:expr) => {}, | ||
| () => {;}, | ||
|
|
||
| } | ||
| } | ||
|
|
||
| x!(test_fields, test_fields2, x, field, MY_CONST); | ||
|
|
||
| pub fn check_fields_local() { | ||
| test_fields!(check_fields); // { dg-error "Failed to match any rule within macro" } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| macro x( | ||
| $macro_name:ident, | ||
| $macro2_name:ident, | ||
| $type_name:ident, | ||
| $field_name:ident, | ||
| $const_name:ident | ||
| ) { | ||
| pub struct $type_name {} | ||
|
|
||
| pub const $const_name: $type_name = $type_name {}; | ||
|
|
||
| #[x] | ||
| // { dg-error "macro not found" "" { target *-*-* } .-1 } | ||
| macro_rules! $macro_name { | ||
| (check_fields) => {{ | ||
| assert_eq!($const_name.field, Field::MacroCtxt); | ||
| }}; | ||
| } | ||
|
|
||
| pub macro $type_name { | ||
| (Copy $e:expr) => {}, | ||
| (check_fields) => {test_fields!(check_fields);}, | ||
|
|
||
| } | ||
| } | ||
|
|
||
| x!(test_fields, test_fields2, x, field, MY_CONST); | ||
|
|
||
| pub fn check_fields_local() { | ||
| test_fields!(check_fields); // { dg-error "Failed to match any rule within macro" } | ||
|
Check failure on line 30 in gcc/testsuite/rust/compile/issue-4187-2.rs
|
||
| test_fields2!(check_fields); // { dg-error "could not resolve macro invocation" } | ||
|
Check failure on line 31 in gcc/testsuite/rust/compile/issue-4187-2.rs
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should prevent
rules_deffrom becoming a dangling pointer (somehow). Maybe by delaying the insertion of names corresponding to macro rules definitions into namespaces until after attributes on the definitions have been processed?