Skip to content

Commit e3231ef

Browse files
committed
gccrs: fix cfg attribute without parentheses error
gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): gcc/testsuite/ChangeLog: * rust/compile/issue-4262.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
1 parent 61a6ea8 commit e3231ef

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

gcc/rust/ast/rust-ast.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4160,16 +4160,10 @@ Attribute::check_cfg_predicate (const Session &session) const
41604160
auto string_path = path.as_string ();
41614161
/* assume that cfg predicate actually can exist, i.e. attribute has cfg or
41624162
* cfg_attr path */
4163-
if (!has_attr_input ()
4164-
|| (string_path != Values::Attributes::CFG
4165-
&& string_path != Values::Attributes::CFG_ATTR))
4163+
if (!has_attr_input ())
41664164
{
4167-
// DEBUG message
4168-
rust_debug (
4169-
"tried to check cfg predicate on attr that either has no input "
4170-
"or invalid path. attr: '%s'",
4171-
as_string ().c_str ());
4172-
4165+
rust_error_at (path.get_locus (), "%<%s%> is not followed by parentheses",
4166+
string_path.c_str ());
41734167
return false;
41744168
}
41754169

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#[cfg]
2+
// { dg-error ".cfg. is not followed by parentheses" "" { target *-*-* } .-1 }
3+
fn a() {}

0 commit comments

Comments
 (0)