Skip to content

Commit 486d641

Browse files
lucasly-baP-E-P
authored andcommitted
gccrs: fix error multiple cfg predicates
gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): Make error. gcc/testsuite/ChangeLog: * rust/compile/issue-4267.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
1 parent 7699f7f commit 486d641

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gcc/rust/ast/rust-ast.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4185,6 +4185,14 @@ Attribute::check_cfg_predicate (const Session &session) const
41854185
"malformed %<cfg_attr%> attribute input");
41864186
return false;
41874187
}
4188+
4189+
if (string_path == Values::Attributes::CFG
4190+
&& meta_item.get_items ().size () != 1)
4191+
{
4192+
rust_error_at (path.get_locus (), "multiple %qs predicates are specified",
4193+
path.as_string ().c_str ());
4194+
return false;
4195+
}
41884196
return meta_item.get_items ().front ()->check_cfg_predicate (session);
41894197
}
41904198

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

0 commit comments

Comments
 (0)