aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/d-lang.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/d/d-lang.cc')
-rw-r--r--gcc/d/d-lang.cc83
1 files changed, 48 insertions, 35 deletions
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 51a87a0..203039e 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -279,12 +279,12 @@ d_init_options (unsigned int, cl_decoded_option *decoded_options)
global.vendor = lang_hooks.name;
global.params.argv0 = xstrdup (decoded_options[0].arg);
global.params.link = true;
- global.params.useAssert = true;
- global.params.useInvariants = true;
- global.params.useIn = true;
- global.params.useOut = true;
- global.params.useArrayBounds = BOUNDSCHECKdefault;
- global.params.useSwitchError = true;
+ global.params.useAssert = CHECKENABLEdefault;
+ global.params.useInvariants = CHECKENABLEdefault;
+ global.params.useIn = CHECKENABLEdefault;
+ global.params.useOut = CHECKENABLEdefault;
+ global.params.useArrayBounds = CHECKENABLEdefault;
+ global.params.useSwitchError = CHECKENABLEdefault;
global.params.useModuleInfo = true;
global.params.useTypeInfo = true;
global.params.useExceptions = true;
@@ -339,9 +339,6 @@ d_init_options_struct (gcc_options *opts)
opts->x_flag_errno_math = 0;
opts->frontend_set_flag_errno_math = true;
- /* Keep in sync with existing -fbounds-check flag. */
- opts->x_flag_bounds_check = global.params.useArrayBounds;
-
/* D says that signed overflow is precisely defined. */
opts->x_flag_wrapv = 1;
}
@@ -424,17 +421,16 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
break;
case OPT_fassert:
- global.params.useAssert = value;
+ global.params.useAssert = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_fbounds_check:
- global.params.useArrayBounds = value
- ? BOUNDSCHECKon : BOUNDSCHECKoff;
+ global.params.useArrayBounds = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_fbounds_check_:
- global.params.useArrayBounds = (value == 2) ? BOUNDSCHECKon
- : (value == 1) ? BOUNDSCHECKsafeonly : BOUNDSCHECKoff;
+ global.params.useArrayBounds = (value == 2) ? CHECKENABLEon
+ : (value == 1) ? CHECKENABLEsafeonly : CHECKENABLEoff;
break;
case OPT_fdebug:
@@ -496,7 +492,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
break;
case OPT_finvariants:
- global.params.useInvariants = value;
+ global.params.useInvariants = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_fmain:
@@ -518,11 +514,11 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
break;
case OPT_fpostconditions:
- global.params.useOut = value;
+ global.params.useOut = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_fpreconditions:
- global.params.useIn = value;
+ global.params.useIn = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_frelease:
@@ -534,7 +530,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
break;
case OPT_fswitch_errors:
- global.params.useSwitchError = value;
+ global.params.useSwitchError = value ? CHECKENABLEon : CHECKENABLEoff;
break;
case OPT_ftransition_all:
@@ -727,29 +723,46 @@ d_post_options (const char ** fn)
*fn = filename;
/* Release mode doesn't turn off bounds checking for safe functions. */
- if (global.params.useArrayBounds == BOUNDSCHECKdefault)
+ if (global.params.useArrayBounds == CHECKENABLEdefault)
{
global.params.useArrayBounds = global.params.release
- ? BOUNDSCHECKsafeonly : BOUNDSCHECKon;
- flag_bounds_check = !global.params.release;
+ ? CHECKENABLEsafeonly : CHECKENABLEon;
}
- if (global.params.release)
+ /* Assert code is generated if unittests are being compiled also, even if
+ release mode is turned on. */
+ if (global.params.useAssert == CHECKENABLEdefault)
{
- if (!global_options_set.x_flag_invariants)
- global.params.useInvariants = false;
+ if (global.params.useUnitTests || !global.params.release)
+ global.params.useAssert = CHECKENABLEon;
+ else
+ global.params.useAssert = CHECKENABLEoff;
+ }
- if (!global_options_set.x_flag_preconditions)
- global.params.useIn = false;
+ /* Checks for switches without a default are turned off in release mode. */
+ if (global.params.useSwitchError == CHECKENABLEdefault)
+ {
+ global.params.useSwitchError = global.params.release
+ ? CHECKENABLEoff : CHECKENABLEon;
+ }
- if (!global_options_set.x_flag_postconditions)
- global.params.useOut = false;
+ /* Contracts are turned off in release mode. */
+ if (global.params.useInvariants == CHECKENABLEdefault)
+ {
+ global.params.useInvariants = global.params.release
+ ? CHECKENABLEoff : CHECKENABLEon;
+ }
- if (!global_options_set.x_flag_assert)
- global.params.useAssert = false;
+ if (global.params.useIn == CHECKENABLEdefault)
+ {
+ global.params.useIn = global.params.release
+ ? CHECKENABLEoff : CHECKENABLEon;
+ }
- if (!global_options_set.x_flag_switch_errors)
- global.params.useSwitchError = false;
+ if (global.params.useOut == CHECKENABLEdefault)
+ {
+ global.params.useOut = global.params.release
+ ? CHECKENABLEoff : CHECKENABLEon;
}
if (global.params.betterC)
@@ -766,6 +779,9 @@ d_post_options (const char ** fn)
global.params.checkAction = CHECKACTION_halt;
}
+ /* Keep in sync with existing -fbounds-check flag. */
+ flag_bounds_check = (global.params.useArrayBounds == CHECKENABLEon);
+
/* Turn off partitioning unless it was explicitly requested, as it doesn't
work with D exception chaining, where EH handler uses LSDA to determine
whether two thrown exception are in the same context. */
@@ -784,9 +800,6 @@ d_post_options (const char ** fn)
if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
flag_excess_precision = EXCESS_PRECISION_STANDARD;
- if (global.params.useUnitTests)
- global.params.useAssert = true;
-
global.params.symdebug = write_symbols != NO_DEBUG;
global.params.useInline = flag_inline_functions;
global.params.showColumns = flag_show_column;