diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-10-17 02:06:34 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-10-17 02:20:51 +0200 |
commit | ef8f7e3f973d90fdffaf4b8e720db484ce63df6f (patch) | |
tree | 552b47ec87801a86a9a6a9fb834c55ce1c9ab13f /gcc/cselib.h | |
parent | e16ace7c79687c224d08ee8d04fd637589333a99 (diff) | |
download | gcc-ef8f7e3f973d90fdffaf4b8e720db484ce63df6f.zip gcc-ef8f7e3f973d90fdffaf4b8e720db484ce63df6f.tar.gz gcc-ef8f7e3f973d90fdffaf4b8e720db484ce63df6f.tar.bz2 |
d: Forbid taking the address of an intrinsic with no implementation
This code fails to link:
import core.math;
real function(real) fn = &sin;
However, when called directly, the D intrinsic `sin()' is expanded by
the front-end into the GCC built-in `__builtin_sin()'. This has been
fixed to now also expand the function when a reference is taken.
As there are D intrinsics and GCC built-ins that don't have a fallback
implementation, raise an error if taking the address is not possible.
gcc/d/ChangeLog:
* d-tree.h (intrinsic_code): Update define for DEF_D_INTRINSIC.
(maybe_reject_intrinsic): New prototype.
* expr.cc (ExprVisitor::visit (SymOffExp *)): Call
maybe_reject_intrinsic.
* intrinsics.cc (intrinsic_decl): Add fallback field.
(intrinsic_decls): Update define for DEF_D_INTRINSIC.
(maybe_reject_intrinsic): New function.
* intrinsics.def (DEF_D_LIB_BUILTIN): Update.
(DEF_CTFE_BUILTIN): Update.
(INTRINSIC_BSF): Declare as library builtin.
(INTRINSIC_BSR): Likewise.
(INTRINSIC_BT): Likewise.
(INTRINSIC_BSF64): Likewise.
(INTRINSIC_BSR64): Likewise.
(INTRINSIC_BT64): Likewise.
(INTRINSIC_POPCNT32): Likewise.
(INTRINSIC_POPCNT64): Likewise.
(INTRINSIC_ROL): Likewise.
(INTRINSIC_ROL_TIARG): Likewise.
(INTRINSIC_ROR): Likewise.
(INTRINSIC_ROR_TIARG): Likewise.
(INTRINSIC_ADDS): Likewise.
(INTRINSIC_ADDSL): Likewise.
(INTRINSIC_ADDU): Likewise.
(INTRINSIC_ADDUL): Likewise.
(INTRINSIC_SUBS): Likewise.
(INTRINSIC_SUBSL): Likewise.
(INTRINSIC_SUBU): Likewise.
(INTRINSIC_SUBUL): Likewise.
(INTRINSIC_MULS): Likewise.
(INTRINSIC_MULSL): Likewise.
(INTRINSIC_MULU): Likewise.
(INTRINSIC_MULUI): Likewise.
(INTRINSIC_MULUL): Likewise.
(INTRINSIC_NEGS): Likewise.
(INTRINSIC_NEGSL): Likewise.
(INTRINSIC_TOPRECF): Likewise.
(INTRINSIC_TOPREC): Likewise.
(INTRINSIC_TOPRECL): Likewise.
gcc/testsuite/ChangeLog:
* gdc.dg/builtins_reject.d: New test.
* gdc.dg/intrinsics_reject.d: New test.
Diffstat (limited to 'gcc/cselib.h')
0 files changed, 0 insertions, 0 deletions