@@ -154,6 +154,12 @@ STATIC_THREAD a_boolean
154154 value of FALSE. */
155155#endif /* MICROSOFT_EXTENSIONS_ALLOWED */
156156
157+ STATIC_THREAD a_boolean
158+ constexpr_exceptions_flag_used;
159+ /* TRUE if constexpr_exceptions_enabled was set or
160+ cleared by a --set_flag or --clear_flag option, so
161+ that the language mode does not determine it. */
162+
157163
158164static void add_config_dependent_option_description(
159165 an_option_kind kind,
@@ -2546,6 +2552,7 @@ STATIC_THREAD a_flag_name
25462552#endif /* IL_SHOULD_BE_WRITTEN_TO_FILE */
25472553 { "extended_float_types", &extended_float_types },
25482554 { "use_predefined_macro_file", &use_predefined_macro_file },
2555+ { "constexpr_exceptions", &constexpr_exceptions_enabled },
25492556 { NULL, NULL } /* must be last */
25502557};
25512558
@@ -2569,6 +2576,9 @@ be given to the flag.
25692576 str_command_line_error(ec_cl_invalid_flag_name, flag_name);
25702577 } /* if */
25712578 *flag_var = value;
2579+ if (flag_var == &constexpr_exceptions_enabled) {
2580+ constexpr_exceptions_flag_used = TRUE;
2581+ } /* if */
25722582} /* set_flag_value */
25732583
25742584
@@ -4449,6 +4459,9 @@ default mode (e.g., exception handling).
44494459 embed_enabled = TRUE;
44504460 struct_binding_packs_enabled = TRUE;
44514461 pack_indexing_enabled = TRUE;
4462+ if (!constexpr_exceptions_flag_used) {
4463+ constexpr_exceptions_enabled = TRUE;
4464+ } /* if */
44524465 } /* if */
44534466 /* Disable "false" as a null pointer constant in C++11 mode (as per Core
44544467 issue 903). */
@@ -12387,6 +12400,17 @@ Process the arguments on the command line that invoked the compiler.
1238712400 } /* if */
1238812401 nonclass_prototype_instantiations = TRUE;
1238912402 } /* if */
12403+ if (!exceptions_enabled) {
12404+ /* Exceptions cannot be thrown during constant evaluation if they cannot be
12405+ thrown at all. */
12406+ constexpr_exceptions_enabled = FALSE;
12407+ } /* if */
12408+ if (constexpr_exceptions_enabled) {
12409+ /* Catching exceptions during constant evaluation requires try-blocks in
12410+ constexpr functions (e.g., with --set_flag=constexpr_exceptions in
12411+ C++17 mode). */
12412+ constexpr_try_enabled = TRUE;
12413+ } /* if */
1239012414 if (lambdas_enabled) {
1239112415 /* If lambdas are allowed, enable local types as template arguments too. */
1239212416 local_types_as_template_args_enabled = TRUE;
@@ -13862,6 +13886,8 @@ variables declared in cmd_line.h.
1386213886 embed_enabled = FALSE;
1386313887 struct_binding_packs_enabled = FALSE;
1386413888 pack_indexing_enabled = FALSE;
13889+ constexpr_exceptions_enabled = FALSE;
13890+ constexpr_exceptions_flag_used = FALSE;
1386513891} /* cmd_line_static_var_init */
1386613892
1386713893
0 commit comments