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.
This commit is contained in:
Richard Biener 2025-03-19 15:02:23 +01:00 committed by Richard Biener
parent 8d236c53c6
commit 56145ae79b
6 changed files with 19 additions and 13 deletions

View 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

View 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);
}

View 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));

View 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,

View 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);

View 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. */