d: Don't generate code that throws exceptions when compiling with `-fno-exceptions'
commitda108c75ad386b3f1f47abb2265296e4b61d578a
authorIain Buclaw <ibuclaw@gdcproject.org>
Sat, 1 Jul 2023 15:01:30 +0000 (1 17:01 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sat, 1 Jul 2023 15:01:30 +0000 (1 17:01 +0200)
tree8a38cd9bf386542f7c07b2ec2daa2871e2b0ea02
parentee4d85b3a8b76328df6bccc1026d62dff5f827ce
d: Don't generate code that throws exceptions when compiling with `-fno-exceptions'

The version flags for RTMI, RTTI, and exceptions was unconditionally
predefined.  These are now only predefined if the feature flag is
enabled.  It was noticed that there was no `-fexceptions' definition
inside d/lang.opt, so the detection of the exceptions option flag was
only partially working.  Once that was fixed, a few places in the
front-end implementation were found to fall fowl of `nothrow' rules,
these have been fixed upstream and backported here as well.

Reviewed-on: https://github.com/dlang/dmd/pull/15357
     https://github.com/dlang/dmd/pull/15360

PR d/110471

gcc/d/ChangeLog:

* d-builtins.cc (d_init_versions): Predefine D_ModuleInfo,
D_Exceptions, and D_TypeInfo only if feature is enabled.
* lang.opt: Add -fexceptions.

gcc/testsuite/ChangeLog:

* gdc.dg/pr110471a.d: New test.
* gdc.dg/pr110471b.d: New test.
* gdc.dg/pr110471c.d: New test.
gcc/d/d-builtins.cc
gcc/d/dmd/root/array.d
gcc/d/dmd/semantic2.d
gcc/d/dmd/semantic3.d
gcc/d/lang.opt
gcc/testsuite/gdc.dg/pr110471a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr110471b.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr110471c.d [new file with mode: 0644]