Skip to content

Commit 95e08b8

Browse files
lucasly-baphilberty
authored andcommitted
gccrs: fix cfg attribute error with literal predicate
gcc/rust/ChangeLog: * ast/rust-ast.cc (MetaItemLitExpr::check_cfg_predicate): Make error. gcc/testsuite/ChangeLog: * rust/compile/issue-4222.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
1 parent d4d1fc1 commit 95e08b8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

gcc/rust/ast/rust-ast.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,6 +3834,9 @@ MetaItemLitExpr::check_cfg_predicate (const Session &) const
38343834
{
38353835
/* as far as I can tell, a literal expr can never be a valid cfg body, so
38363836
* false */
3837+
rust_error_at (this->get_locus (), "'%s' predicate key cannot be a literal",
3838+
this->as_string ().c_str ());
3839+
38373840
return false;
38383841
}
38393842

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![cfg(false)]
2+
// { dg-error ".false. predicate key cannot be a literal" "" { target *-*-* } .-1 }
3+
fn a() {}

0 commit comments

Comments
 (0)