* [committed] d: Define language hook for LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
@ 2021-03-28 15:53 Iain Buclaw
0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-03-28 15:53 UTC (permalink / raw)
To: gcc-patches
Hi,
This patch defines LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE for the D
front-end, the underlying base type for enumerals are always present in
TREE_TYPE.
Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, and
committed to mainline.
Regards,
Iain
---
gcc/d/ChangeLog:
* d-lang.cc (d_enum_underlying_base_type): New function.
(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Set as
d_enum_underlying_base_type.
---
gcc/d/d-lang.cc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 0720cba1340..5028698a5bc 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1719,6 +1719,16 @@ d_build_eh_runtime_type (tree type)
return convert (ptr_type_node, build_address (decl));
}
+/* Implements the lang_hooks.enum_underlying_base_type routine for language D.
+ Returns the underlying type of the given enumeration TYPE. */
+
+static tree
+d_enum_underlying_base_type (const_tree type)
+{
+ gcc_assert (TREE_CODE (type) == ENUMERAL_TYPE);
+ return TREE_TYPE (type);
+}
+
/* Definitions for our language-specific hooks. */
#undef LANG_HOOKS_NAME
@@ -1744,6 +1754,7 @@ d_build_eh_runtime_type (tree type)
#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
#undef LANG_HOOKS_EH_PERSONALITY
#undef LANG_HOOKS_EH_RUNTIME_TYPE
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
#undef LANG_HOOKS_PUSHDECL
#undef LANG_HOOKS_GETDECLS
#undef LANG_HOOKS_GLOBAL_BINDINGS_P
@@ -1774,6 +1785,7 @@ d_build_eh_runtime_type (tree type)
#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL d_dup_lang_specific_decl
#define LANG_HOOKS_EH_PERSONALITY d_eh_personality
#define LANG_HOOKS_EH_RUNTIME_TYPE d_build_eh_runtime_type
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE d_enum_underlying_base_type
#define LANG_HOOKS_PUSHDECL d_pushdecl
#define LANG_HOOKS_GETDECLS d_getdecls
#define LANG_HOOKS_GLOBAL_BINDINGS_P d_global_bindings_p
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-28 15:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 15:53 [committed] d: Define language hook for LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE Iain Buclaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).