public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-7877] d: Define language hook for LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE Date: Sun, 28 Mar 2021 15:47:43 +0000 (GMT) [thread overview] Message-ID: <20210328154743.AAFA7385703C@sourceware.org> (raw) https://gcc.gnu.org/g:0907036f4541cfb51a626ef13c282f7be2098add commit r11-7877-g0907036f4541cfb51a626ef13c282f7be2098add Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Sat Mar 27 02:31:45 2021 +0100 d: Define language hook for LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE The underlying base type for enumerals are always present in TREE_TYPE. 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. Diff: --- 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
reply other threads:[~2021-03-28 15:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210328154743.AAFA7385703C@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).