]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: proc macro: Detect malformed proc_macro_derive
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 18 Jul 2023 11:37:03 +0000 (13:37 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:55:57 +0000 (18:55 +0100)
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 <pierre-emmanuel.patry@embecosm.com>
gcc/rust/util/rust-attributes.cc

index a174edc625f50cd9e9baa72837c9392d6baa04ad..c8451def94ebef279aea33e1c0b8d7b1652e13ca 100644 (file)
@@ -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"