aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2023-05-21 20:23:27 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2023-05-22 08:08:20 +0000
commit1666b77ead3d1c468aca01def5559b8b6d48bf84 (patch)
treee5f2a3e7634155ee004368f5028e74ec66857f65 /gcc
parent003ac98771e6f8c4ba6b9878a925f61cc9d6c6e5 (diff)
downloadgcc-1666b77ead3d1c468aca01def5559b8b6d48bf84.zip
gcc-1666b77ead3d1c468aca01def5559b8b6d48bf84.tar.gz
gcc-1666b77ead3d1c468aca01def5559b8b6d48bf84.tar.bz2
gccrs: Only check first item of cfg_attr attribute as predicate
In #[cfg_attr(A, B, C(D))], only A is a predicate. gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): Only check first item as a predicate. gcc/testsuite/ChangeLog: * rust/compile/cfg-attr.rs: New test. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast.cc3
-rw-r--r--gcc/testsuite/rust/compile/cfg-attr.rs7
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 9a53359..36f1a0c 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -4183,7 +4183,8 @@ Attribute::check_cfg_predicate (const Session &session) const
if (!is_parsed_to_meta_item ())
return false;
- return attr_input->check_cfg_predicate (session);
+ auto &meta_item = static_cast<AttrInputMetaItemContainer &> (*attr_input);
+ return meta_item.get_items ().front ()->check_cfg_predicate (session);
}
std::vector<Attribute>
diff --git a/gcc/testsuite/rust/compile/cfg-attr.rs b/gcc/testsuite/rust/compile/cfg-attr.rs
new file mode 100644
index 0000000..137ed2c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/cfg-attr.rs
@@ -0,0 +1,7 @@
+// { dg-additional-options "-w -frust-cfg=A" }
+#![cfg_attr(not(B), allow(dead_code))]
+#![cfg_attr(A, allow(while_true))]
+
+#[cfg_attr(not(B), allow(deprecated))]
+#[cfg_attr(A, allow(drop_bounds))]
+fn main() { }