diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-07-25 23:19:36 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-07-28 13:13:05 +0200 |
commit | b2f6e1de242fff5713763cd3146dcf3f9dee51ca (patch) | |
tree | b5e25559184ca505e2a59645a742ae9d8185b549 /gcc/d/d-lang.cc | |
parent | 3e2136117487fa839f7601c3e22a2856978fb9d0 (diff) | |
download | gcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.zip gcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.tar.gz gcc-b2f6e1de242fff5713763cd3146dcf3f9dee51ca.tar.bz2 |
d: Compile-time reflection for supported built-ins (PR101127)
In order to allow user-code to determine whether a back-end builtin is
available without error, LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE has been
defined to delay putting back-end builtin functions until the ISA that
defines them has been declared.
However in D, there is no global namespace. All builtins get pushed
into the `gcc.builtins' module, which is constructed during the semantic
analysis pass, which has already finished by the time target attributes
are evaluated. So builtins are not pushed by the new langhook because
they would be ultimately ignored. Builtins exposed to D code then can
now only be altered by the command-line.
PR d/101127
gcc/d/ChangeLog:
* d-builtins.cc (d_builtin_function_ext_scope): New function.
* d-lang.cc (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): Define.
* d-tree.h (d_builtin_function_ext_scope): Declare.
gcc/testsuite/ChangeLog:
* gdc.dg/pr101127a.d: New test.
* gdc.dg/pr101127b.d: New test.
Diffstat (limited to 'gcc/d/d-lang.cc')
-rw-r--r-- | gcc/d/d-lang.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index a65af29..6ad3823 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -1745,6 +1745,7 @@ d_enum_underlying_base_type (const_tree type) #undef LANG_HOOKS_GET_ALIAS_SET #undef LANG_HOOKS_TYPES_COMPATIBLE_P #undef LANG_HOOKS_BUILTIN_FUNCTION +#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL #undef LANG_HOOKS_GIMPLIFY_EXPR @@ -1776,6 +1777,7 @@ d_enum_underlying_base_type (const_tree type) #define LANG_HOOKS_GET_ALIAS_SET d_get_alias_set #define LANG_HOOKS_TYPES_COMPATIBLE_P d_types_compatible_p #define LANG_HOOKS_BUILTIN_FUNCTION d_builtin_function +#define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE d_builtin_function_ext_scope #define LANG_HOOKS_REGISTER_BUILTIN_TYPE d_register_builtin_type #define LANG_HOOKS_FINISH_INCOMPLETE_DECL d_finish_incomplete_decl #define LANG_HOOKS_GIMPLIFY_EXPR d_gimplify_expr |