From: Lucas Ly Ba Date: Thu, 6 Nov 2025 16:53:00 +0000 (+0000) Subject: gccrs: fix error multiple cfg predicates X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc139172ea3a9e5b4976049933136b1b9e5be98;p=thirdparty%2Fgcc.git 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 --- 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(){}