]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make function_decl_type a scoped enum
authorRichard Biener <rguenther@suse.de>
Wed, 19 Mar 2025 14:02:23 +0000 (15:02 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 20 Mar 2025 09:07:54 +0000 (10:07 +0100)
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.

gcc/config/aarch64/aarch64-simd-pragma-builtins.def
gcc/cp/module.cc
gcc/lto-streamer-out.cc
gcc/tree-core.h
gcc/tree-streamer-out.cc
gcc/tree.h

index 2c0dc11b0553ea4ce288e0a30b9f1e4267ec0de8..7768236510318bd80205ac6cd0451e1e43496667 100644 (file)
@@ -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
 
index 0d9e50bba7f9d2f5df2858623754a80e929da4af..beceafe05f6b5aea1b1b223705cbc3379af75987 100644 (file)
@@ -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);
     }
index 96eb79b22897c401e88d2bf2ce0348c556f4e23b..d5b6ee74d573034c1edbed83590f8783f9b1a66c 100644 (file)
@@ -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));
index 6e76d2bdb80cf063cb3b606781be6513119d7e83..bd19c99d326242f4eae1dd23b3eb90d18351a4c9 100644 (file)
@@ -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,
index 0b61422c54161b3abe2915e2f6938a3af5f3473b..34227259b8aaadfd53484fb1454553a753b90f96 100644 (file)
@@ -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);
index 6f45359f103d934045f0a087e5ee988e89ea539c..55f97f9f99947e6ee698b7ff1a32be44ce2781ac 100644 (file)
@@ -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.  */