diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 337a338f9a3..5bced483adb 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -4185,6 +4185,14 @@ Attribute::check_cfg_predicate (const Session &session) const "malformed % attribute input"); return false; } + + if (string_path == Values::Attributes::CFG + && meta_item.get_items ().size () != 1) + { + rust_error_at (path.get_locus (), "multiple %qs predicates are specified", + path.as_string ().c_str ()); + return false; + } return meta_item.get_items ().front ()->check_cfg_predicate (session); } diff --git a/gcc/testsuite/rust/compile/issue-4267.rs b/gcc/testsuite/rust/compile/issue-4267.rs new file mode 100644 index 00000000000..f507748c694 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-4267.rs @@ -0,0 +1,3 @@ +#[cfg(a,a)] +// { dg-error "multiple .cfg. predicates are specified" "" { target *-*-* } .-1 } +fn a(){}