https://gcc.gnu.org/g:56145ae79b89b823f306c2c241f6a1fe5d604816

commit r15-8464-g56145ae79b89b823f306c2c241f6a1fe5d604816
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Mar 19 15:02:23 2025 +0100

    Make function_decl_type a scoped enum
    
    The enum currently has a member named NONE which pollutes the global
    namespace unnecessarily.  Use a scoped enum instead.
    
    gcc/
            * tree-core.h (function_decl_type): Make a scoped enum.
            * tree.h (set_function_decl_type): Adjust.
            (DECL_IS_OPERATOR_NEW_P): Likewise.
            (DECL_SET_IS_OPERATOR_NEW): Likewise.
            (DECL_IS_OPERATOR_DELETE_P): Likewise.
            (DECL_SET_IS_OPERATOR_DELETE): Likewise.
            (DECL_LAMBDA_FUNCTION_P): Likewise.
            (DECL_SET_LAMBDA_FUNCTION): Likewise.
            * lto-streamer-out.cc (hash_tree): Hash all of
            FUNCTION_DECL_DECL_TYPE.
            * tree-streamer-out.cc (pack_ts_function_decl_value_fields):
            Adjust.
            * config/aarch64/aarch64-simd-pragma-builtins.def (vcombine_mf8):
            Use literal zero instead of NONE.
    
    gcc/cp/
            * module.cc (trees_out::core_bools): Convert scoped enum
            explicitly.

Diff:
---
 .../aarch64/aarch64-simd-pragma-builtins.def       |  2 +-
 gcc/cp/module.cc                                   |  2 +-
 gcc/lto-streamer-out.cc                            |  2 +-
 gcc/tree-core.h                                    |  2 +-
 gcc/tree-streamer-out.cc                           |  2 +-
 gcc/tree.h                                         | 22 ++++++++++++++--------
 6 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def 
b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
index 2c0dc11b0553..776823651031 100644
--- a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
@@ -203,7 +203,7 @@ ENTRY_TERNARY (vbslq_mf8, mf8q, u8q, mf8q, mf8q, 
UNSPEC_BSL, QUIET)
 #undef REQUIRED_EXTENSIONS
 
 // combine
-#define REQUIRED_EXTENSIONS nonstreaming_only (NONE)
+#define REQUIRED_EXTENSIONS nonstreaming_only (0)
 ENTRY_BINARY (vcombine_mf8, mf8q, mf8, mf8, UNSPEC_COMBINE, QUIET)
 #undef REQUIRED_EXTENSIONS
 
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 0d9e50bba7f9..beceafe05f6b 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -5757,7 +5757,7 @@ trees_out::core_bools (tree t, bits_out& bits)
       WB (t->function_decl.replaceable_operator);
 
       /* decl_type is a (misnamed) 2 bit discriminator.         */
-      unsigned kind = t->function_decl.decl_type;
+      unsigned kind = (unsigned)t->function_decl.decl_type;
       WB ((kind >> 0) & 1);
       WB ((kind >> 1) & 1);
     }
diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index 96eb79b22897..d5b6ee74d573 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -1333,7 +1333,7 @@ hash_tree (struct streamer_tree_cache_d *cache, 
hash_map<tree, hashval_t> *map,
       hstate.add_int (DECL_BUILT_IN_CLASS (t));
       hstate.add_flag (DECL_STATIC_CONSTRUCTOR (t));
       hstate.add_flag (DECL_STATIC_DESTRUCTOR (t));
-      hstate.add_flag (FUNCTION_DECL_DECL_TYPE (t));
+      hstate.add_int ((unsigned)FUNCTION_DECL_DECL_TYPE (t));
       hstate.add_flag (DECL_UNINLINABLE (t));
       hstate.add_flag (DECL_POSSIBLY_INLINED (t));
       hstate.add_flag (DECL_IS_NOVOPS (t));
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 6e76d2bdb80c..bd19c99d3262 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -2023,7 +2023,7 @@ struct GTY(()) tree_decl_non_common {
 
 /* Classify a special function declaration type.  */
 
-enum function_decl_type
+enum class function_decl_type : unsigned
 {
   NONE,
   OPERATOR_NEW,
diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
index 0b61422c5416..34227259b8aa 100644
--- a/gcc/tree-streamer-out.cc
+++ b/gcc/tree-streamer-out.cc
@@ -306,7 +306,7 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, 
tree expr)
   bp_pack_value (bp, DECL_IS_NOVOPS (expr), 1);
   bp_pack_value (bp, DECL_IS_RETURNS_TWICE (expr), 1);
   bp_pack_value (bp, DECL_IS_MALLOC (expr), 1);
-  bp_pack_value (bp, FUNCTION_DECL_DECL_TYPE (expr), 2);
+  bp_pack_value (bp, (unsigned)FUNCTION_DECL_DECL_TYPE (expr), 2);
   bp_pack_value (bp, DECL_IS_OPERATOR_DELETE_P (expr), 1);
   bp_pack_value (bp, DECL_DECLARED_INLINE_P (expr), 1);
   bp_pack_value (bp, DECL_STATIC_CHAIN (expr), 1);
diff --git a/gcc/tree.h b/gcc/tree.h
index 6f45359f103d..55f97f9f9994 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3424,12 +3424,12 @@ set_function_decl_type (tree decl, function_decl_type 
t, bool set)
 {
   if (set)
     {
-      gcc_assert (FUNCTION_DECL_DECL_TYPE (decl) == NONE
+      gcc_assert (FUNCTION_DECL_DECL_TYPE (decl) == function_decl_type::NONE
                  || FUNCTION_DECL_DECL_TYPE (decl) == t);
       FUNCTION_DECL_DECL_TYPE (decl) = t;
     }
   else if (FUNCTION_DECL_DECL_TYPE (decl) == t)
-    FUNCTION_DECL_DECL_TYPE (decl) = NONE;
+    FUNCTION_DECL_DECL_TYPE (decl) = function_decl_type::NONE;
 }
 
 /* Nonzero in a FUNCTION_DECL means this function is a replaceable
@@ -3441,21 +3441,25 @@ set_function_decl_type (tree decl, function_decl_type 
t, bool set)
    C++ operator new, meaning that it returns a pointer for which we
    should not use type based aliasing.  */
 #define DECL_IS_OPERATOR_NEW_P(NODE) \
-  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == OPERATOR_NEW)
+  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) \
+   == function_decl_type::OPERATOR_NEW)
 
 #define DECL_IS_REPLACEABLE_OPERATOR_NEW_P(NODE) \
   (DECL_IS_OPERATOR_NEW_P (NODE) && DECL_IS_REPLACEABLE_OPERATOR (NODE))
 
 #define DECL_SET_IS_OPERATOR_NEW(NODE, VAL) \
-  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), OPERATOR_NEW, VAL)
+  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), \
+                         function_decl_type::OPERATOR_NEW, VAL)
 
 /* Nonzero in a FUNCTION_DECL means this function should be treated as
    C++ operator delete.  */
 #define DECL_IS_OPERATOR_DELETE_P(NODE) \
-  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == OPERATOR_DELETE)
+  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) \
+   == function_decl_type::OPERATOR_DELETE)
 
 #define DECL_SET_IS_OPERATOR_DELETE(NODE, VAL) \
-  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), OPERATOR_DELETE, VAL)
+  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), \
+                         function_decl_type::OPERATOR_DELETE, VAL)
 
 /* Nonzero in a FUNCTION_DECL means this function may return more
    than once.  */
@@ -3603,10 +3607,12 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 
 /* In FUNCTION_DECL, this is set if this function is a lambda function.  */
 #define DECL_LAMBDA_FUNCTION_P(NODE) \
-  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == LAMBDA_FUNCTION)
+  (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) \
+   == function_decl_type::LAMBDA_FUNCTION)
 
 #define DECL_SET_LAMBDA_FUNCTION(NODE, VAL) \
-  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), LAMBDA_FUNCTION, VAL)
+  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), \
+                         function_decl_type::LAMBDA_FUNCTION, VAL)
 
 /* In FUNCTION_DECL that represent an virtual method this is set when
    the method is final.  */

Reply via email to