[gcc r16-8209] gccrs: Use Attribute node status for AttributeChecker

Arthur Cohen cohenarthur@gcc.gnu.org
Fri Mar 20 17:24:43 GMT 2026


https://gcc.gnu.org/g:43bcfb6d5779bad0d34b6693f0872fdcd7163f5a

commit r16-8209-g43bcfb6d5779bad0d34b6693f0872fdcd7163f5a
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Thu Feb 19 15:47:11 2026 +0100

    gccrs: Use Attribute node status for AttributeChecker
    
    Remove attribute specific checking, use default ast visitor instead.
    
    gcc/rust/ChangeLog:
    
            * util/rust-attributes.cc (AttributeChecker::visit): Rename function
            and make call to ast default visitor.
            (AttributeChecker::check_attribute): Remove function.
            * util/rust-attributes.h: Add function prototype.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/util/rust-attributes.cc | 9 ++++-----
 gcc/rust/util/rust-attributes.h  | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 719a972c9d1b..3fe01c4ff8ea 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -192,7 +192,6 @@ AttributeChecker::visit (AST::Crate &crate)
   for (auto &attr : crate.get_inner_attrs ())
     {
       check_inner_attribute (attr);
-      check_attribute (attr);
     }
 
   for (auto &item : crate.items)
@@ -551,7 +550,7 @@ check_lint_attribute (const AST::Attribute &attribute, const char *name)
 }
 
 void
-AttributeChecker::check_attribute (const AST::Attribute &attribute)
+AttributeChecker::visit (AST::Attribute &attribute)
 {
   if (!attribute.empty_input ())
     {
@@ -892,7 +891,6 @@ AttributeChecker::visit (AST::Module &module)
   for (auto &attr : module.get_outer_attrs ())
     {
       check_valid_attribute_for_item (attr, module);
-      check_attribute (attr);
       check_proc_macro_non_function (attr);
     }
 
@@ -1067,9 +1065,10 @@ AttributeChecker::visit (AST::StructStruct &struct_item)
   for (auto &attr : struct_item.get_outer_attrs ())
     {
       check_valid_attribute_for_item (attr, struct_item);
-      check_attribute (attr);
       check_proc_macro_non_function (attr);
     }
+
+  AST::DefaultASTVisitor::visit (struct_item);
 }
 
 void
@@ -1157,8 +1156,8 @@ AttributeChecker::visit (AST::Trait &trait)
     {
       check_valid_attribute_for_item (attr, trait);
       check_proc_macro_non_function (attr);
-      check_attribute (attr);
     }
+  AST::DefaultASTVisitor::visit (trait);
 }
 
 void
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index bae160167e62..f63f902363c3 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -106,9 +106,9 @@ private:
   /* Check the validity of an inner attribute */
   void check_inner_attribute (const AST::Attribute &attribute);
   /* Check the validity of a given attribute */
-  void check_attribute (const AST::Attribute &attribute);
 
   // rust-ast.h
+  void visit (AST::Attribute &attribute) override;
   void visit (AST::Crate &crate) override;
   void visit (AST::Token &tok) override;
   void visit (AST::DelimTokenTree &delim_tok_tree) override;


More information about the Gcc-cvs mailing list