From 1b1f8d898857b69b98095fc26b4dd95bafffdc18 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Tue, 18 Jul 2023 13:37:03 +0200 Subject: [PATCH] gccrs: 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(+) diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index a174edc625f5..c8451def94eb 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" -- 2.47.2