From: Guillaume Gomez <[email protected]>

gcc/rust/ChangeLog:

        * rust-attribs.cc (handle_noreturn_attribute)
        (rust_handle_noreturn_attribute, handle_malloc_attribute)
        (rust_handle_malloc_attribute, handle_nonnull_attribute)
        (rust_handle_nonnull_attribute, handle_transaction_pure_attribute)
        (rust_handle_transaction_pure_attribute)
        (handle_omp_declare_simd_attribute)
        (rust_handle_omp_declare_simd_attribute, handle_cold_attribute)
        (handle_hot_attribute, rust_handle_cold_attribute)
        (rust_handle_hot_attribute): Prepend functions with `rust_`
---
Follow-up of https://forge.sourceware.org/gcc/gcc/pulls/241.

In particular, @dkm suggested 
[here](https://forge.sourceware.org/gcc/gcc/pulls/244#issuecomment-7865) to 
prepend all Ada attribute handling functions to prevent name conflicts and I 
think it's a very good idea, so I'm doing it here as well.

cc @cohenarthur



This is a forge pull request published on the gcc-patches mailing list mailing 
list
as requested by Guillaume Gomez via Sourceware Forge 
<[email protected]>.
Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/273

Get it locally using:
```
git fetch forge-upstream "+refs/versioned_pull/273/*:refs/versioned_pull/273/*"
git switch -c "pr-273-v2" "refs/versioned_pull/273/2/head"
```
Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/273.diff
Created on: 2026-11-12 15:19:12+00:00
Latest update: 2026-11-12 15:28:01+00:00
Changes: 1 changed files, 27 additions, 24 deletions
Head revision: imperio/gcc ref rust-attr-conflict commit 
5dcde4d95cb05a224ba1e7f3ede1e3272886d9c5 
Base revision: gcc/gcc ref trunk commit 
d20952792b133c691be69a2bfdb71e1956592956 r17-6173-gd20952792b133c
Merge base: d20952792b133c691be69a2bfdb71e1956592956
Requested Reviewers: cohenarthur

Changed files:
- M: gcc/rust/rust-attribs.cc

 gcc/rust/rust-attribs.cc | 51 +++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/gcc/rust/rust-attribs.cc b/gcc/rust/rust-attribs.cc
index a6ae3f34a46c0..34afb0e19c030 100644
--- a/gcc/rust/rust-attribs.cc
+++ b/gcc/rust/rust-attribs.cc
@@ -43,22 +43,24 @@ extern const struct scoped_attribute_specs 
grs_langhook_gnu_attribute_table;
 extern const struct scoped_attribute_specs grs_langhook_common_attribute_table;
 
 /* Internal attribute handlers for built-in functions.  */
-static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
+static tree rust_handle_noreturn_attribute (tree *, tree, tree, int, bool *);
 static tree rust_handle_leaf_attribute (tree *, tree, tree, int, bool *);
 static tree rust_handle_const_attribute (tree *, tree, tree, int, bool *);
-static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
+static tree rust_handle_malloc_attribute (tree *, tree, tree, int, bool *);
 static tree rust_handle_pure_attribute (tree *, tree, tree, int, bool *);
 static tree rust_handle_novops_attribute (tree *, tree, tree, int, bool *);
-static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
+static tree rust_handle_nonnull_attribute (tree *, tree, tree, int, bool *);
 static tree rust_handle_nothrow_attribute (tree *, tree, tree, int, bool *);
-static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool 
*);
+static tree rust_handle_transaction_pure_attribute (tree *, tree, tree, int,
+                                                   bool *);
 static tree rust_handle_returns_twice_attribute (tree *, tree, tree, int,
                                                 bool *);
-static tree handle_omp_declare_simd_attribute (tree *, tree, tree, int, bool 
*);
+static tree rust_handle_omp_declare_simd_attribute (tree *, tree, tree, int,
+                                                   bool *);
 
 /* Rust attribute handlers for user defined attributes.  */
-static tree handle_cold_attribute (tree *, tree, tree, int, bool *);
-static tree handle_hot_attribute (tree *, tree, tree, int, bool *);
+static tree rust_handle_cold_attribute (tree *, tree, tree, int, bool *);
+static tree rust_handle_hot_attribute (tree *, tree, tree, int, bool *);
 
 /* Helper to define attribute exclusions.  */
 #define ATTR_EXCL(name, function, type, variable)                              
\
@@ -103,24 +105,24 @@ static const struct attribute_spec::exclusions 
rust_attr_const_pure_exclusions[]
    For internal use (marking of built-ins) only.  */
 static const attribute_spec grs_langhook_common_attributes[] = {
   ATTR_SPEC ("noreturn", 0, 0, true, false, false, false,
-            handle_noreturn_attribute, rust_attr_noreturn_exclusions),
+            rust_handle_noreturn_attribute, rust_attr_noreturn_exclusions),
   ATTR_SPEC ("leaf", 0, 0, true, false, false, false,
             rust_handle_leaf_attribute, NULL),
   ATTR_SPEC ("const", 0, 0, true, false, false, false,
             rust_handle_const_attribute, rust_attr_const_pure_exclusions),
-  ATTR_SPEC ("malloc", 0, 0, true, false, false, false, 
handle_malloc_attribute,
-            NULL),
+  ATTR_SPEC ("malloc", 0, 0, true, false, false, false,
+            rust_handle_malloc_attribute, NULL),
   ATTR_SPEC ("returns_twice", 0, 0, true, false, false, false,
             rust_handle_returns_twice_attribute,
             attr_returns_twice_exclusions),
   ATTR_SPEC ("pure", 0, 0, true, false, false, false,
             rust_handle_pure_attribute, rust_attr_const_pure_exclusions),
   ATTR_SPEC ("nonnull", 0, -1, false, true, true, false,
-            handle_nonnull_attribute, NULL),
+            rust_handle_nonnull_attribute, NULL),
   ATTR_SPEC ("nothrow", 0, 0, true, false, false, false,
             rust_handle_nothrow_attribute, NULL),
   ATTR_SPEC ("transaction_pure", 0, 0, false, true, true, false,
-            handle_transaction_pure_attribute, NULL),
+            rust_handle_transaction_pure_attribute, NULL),
   ATTR_SPEC ("no vops", 0, 0, true, false, false, false,
             rust_handle_novops_attribute, NULL),
   ATTR_SPEC ("type generic", 0, 0, false, true, true, false,
@@ -128,16 +130,16 @@ static const attribute_spec 
grs_langhook_common_attributes[] = {
   ATTR_SPEC ("fn spec", 1, 1, false, true, true, false, 
handle_fnspec_attribute,
             NULL),
   ATTR_SPEC ("omp declare simd", 0, -1, true, false, false, false,
-            handle_omp_declare_simd_attribute, NULL),
+            rust_handle_omp_declare_simd_attribute, NULL),
 };
 
 const scoped_attribute_specs grs_langhook_common_attribute_table
   = {"gnu", {grs_langhook_common_attributes}};
 
 static const attribute_spec grs_langhook_gnu_attributes[] = {
-  ATTR_SPEC ("cold", 0, 0, true, false, false, false, handle_cold_attribute,
-            attr_cold_hot_exclusions),
-  ATTR_SPEC ("hot", 0, 0, true, false, false, false, handle_hot_attribute,
+  ATTR_SPEC ("cold", 0, 0, true, false, false, false,
+            rust_handle_cold_attribute, attr_cold_hot_exclusions),
+  ATTR_SPEC ("hot", 0, 0, true, false, false, false, rust_handle_hot_attribute,
             attr_cold_hot_exclusions),
 };
 
@@ -152,7 +154,7 @@ const scoped_attribute_specs 
grs_langhook_gnu_attribute_table
    struct attribute_spec.handler.  */
 
 static tree
-handle_noreturn_attribute (tree *node, tree, tree, int, bool *)
+rust_handle_noreturn_attribute (tree *node, tree, tree, int, bool *)
 {
   tree type = TREE_TYPE (*node);
 
@@ -215,7 +217,7 @@ rust_handle_const_attribute (tree *node, tree, tree, int, 
bool *)
    struct attribute_spec.handler.  */
 
 static tree
-handle_malloc_attribute (tree *node, tree, tree, int, bool *)
+rust_handle_malloc_attribute (tree *node, tree, tree, int, bool *)
 {
   gcc_assert (TREE_CODE (*node) == FUNCTION_DECL
              && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))));
@@ -274,7 +276,7 @@ get_nonnull_operand (tree arg_num_expr, unsigned 
HOST_WIDE_INT *valp)
 /* Handle the "nonnull" attribute.  */
 
 static tree
-handle_nonnull_attribute (tree *node, tree, tree args, int, bool *)
+rust_handle_nonnull_attribute (tree *node, tree, tree args, int, bool *)
 {
   tree type = *node;
 
@@ -340,7 +342,7 @@ rust_handle_nothrow_attribute (tree *node, tree name, tree, 
int,
    struct attribute_spec.handler.  */
 
 static tree
-handle_transaction_pure_attribute (tree *node, tree, tree, int, bool *)
+rust_handle_transaction_pure_attribute (tree *node, tree, tree, int, bool *)
 {
   /* Ensure we have a function type.  */
   gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
@@ -370,8 +372,8 @@ rust_handle_returns_twice_attribute (tree *node, tree name, 
tree, int,
    struct attribute_spec.handler.  */
 
 static tree
-handle_omp_declare_simd_attribute (tree *node, tree name, tree, int,
-                                  bool *no_add_attrs)
+rust_handle_omp_declare_simd_attribute (tree *node, tree name, tree, int,
+                                       bool *no_add_attrs)
 {
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {
@@ -390,7 +392,8 @@ handle_omp_declare_simd_attribute (tree *node, tree name, 
tree, int,
    struct attribute_spec.handler.  */
 
 static tree
-handle_cold_attribute (tree *node, tree name, tree, int, bool *no_add_attrs)
+rust_handle_cold_attribute (tree *node, tree name, tree, int,
+                           bool *no_add_attrs)
 {
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {
@@ -402,7 +405,7 @@ handle_cold_attribute (tree *node, tree name, tree, int, 
bool *no_add_attrs)
 }
 
 static tree
-handle_hot_attribute (tree *node, tree name, tree, int, bool *no_add_attrs)
+rust_handle_hot_attribute (tree *node, tree name, tree, int, bool 
*no_add_attrs)
 {
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {

Range-diff against v1:
1:  4e05e4ca271de ! 1:  5dcde4d95cb05 Rename attribute handling functions to 
prevent accidental name conflict with `attr-handlers.h`.
    @@ Metadata
     Author: Guillaume Gomez <[email protected]>
     
      ## Commit message ##
    -    Rename attribute handling functions to prevent accidental
    -    name conflict with `attr-handlers.h`.
    +    Rename Rust attribute handling functions.
     
         gcc/rust/ChangeLog:
     
-- 
2.56.0

Reply via email to