From d6912fb38b96b3989cd009bde1c36e659e0bdd70 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Tue, 18 Jul 2023 13:37:03 +0200 Subject: proc macro: Detect malformed proc_macro_derive A derive procedural macro declaration shall always have at least a trait to refer to. We should error out when it doesn't. gcc/rust/ChangeLog: * util/rust-attributes.cc (AttributeChecker::visit): Add attribute input check. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/util/rust-attributes.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index e5670f9..1d2907b 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -561,6 +561,11 @@ AttributeChecker::visit (AST::Function &fun) if (result.name == "proc_macro_derive") { + if (!attribute.has_attr_input ()) + { + rust_error_at (attribute.get_locus (), + "malformed %<%s%> attribute input", name); + } check_crate_type (name, attribute); } else if (result.name == "proc_macro" -- cgit v1.1