From: Lucas Ly Ba <[email protected]>
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 <[email protected]>
---
gcc/rust/ast/rust-ast.cc | 8 ++++++++
gcc/testsuite/rust/compile/issue-4267.rs | 3 +++
2 files changed, 11 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/issue-4267.rs
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 %<cfg_attr%> 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(){}
--
2.50.1