@@ -25854,83 +25854,23 @@ compound statement of that handler.
2585425854 goto continue_mem_inits;
2585525855 } /* if */
2585625856
25857- /* Retrieve the routine scope, or issue an error. */
2585825857 if (callee == NULL) {
2585925858 info_with_pos(ec_constexpr_expression_cannot_be_interpreted, pos, ips);
2586025859 do_constexpr_fail(result);
2586125860 goto done;
25862- } else if (!callee->is_constexpr) {
25863- info_with_pos_sym(ec_constexpr_call_to_nonconstexpr_function,
25864- pos, symbol_for(callee), ips);
25865- do_constexpr_fail(result);
25866- goto done;
25867- } /* if */
25868- if (!callee->defined) {
25869- if (has_routine_definition_from_module(callee)) {
25870- /* The definition was stored in a module file. */
25871- if (!load_routine_definition_from_module(callee)) {
25872- ips->input_error = TRUE;
25873- do_constexpr_fail(result);
25874- } /* if */
25875- } else if ((callee->is_inheriting_ctor || callee->compiler_generated) &&
25876- !callee->is_deleted) {
25877- force_definition_of_compiler_generated_routine(callee);
25878- } else {
25879- set_instance_required(symbol_for(callee), TRUE, SIR_CONSTANT_CONTEXT);
25880- } /* if */
25881- } /* if */
25882- if (callee->function_def_number == NULL_function_def_number) {
25883- info_with_pos_sym(ec_constexpr_function_undefined, pos,
25884- symbol_for(callee), ips);
25885- do_constexpr_fail(result);
25886- if (callee->is_deleted && ips->is_constant_evaluated) {
25887- /* An error has presumably been issued earlier (use of a deleted
25888- function). Treat this as an input error to avoid extraneous
25889- diagnostics. */
25890- expect_error();
25891- ips->input_error = TRUE;
25892- } /* if */
25893- goto done;
25894- } else if (callee->is_prototype_instantiation) {
25895- info_with_pos_sym(ec_constexpr_call_not_interpretable, pos,
25896- symbol_for(callee), ips);
25897- do_constexpr_fail(result);
25898- goto done;
25899- } else if (cost_exceeded(ips)) {
25900- report_excessive_cost(ips);
25901- do_constexpr_fail(result);
25902- goto done;
2590325861 } else {
2590425862 a_byte *result_storage = cap.address;
2590525863 a_byte *complete_object = cap.complete_object;
25906- a_scope_ptr callee_scope = scope_for_routine(callee) ;
25864+ a_scope_ptr callee_scope;
2590725865 an_expr_node_ptr args = dip->variant.constructor.args, arg;
25908- a_variable_ptr params = callee_scope->variant.routine.parameters,
25909- param, this_var;
25866+ a_variable_ptr params, param, this_var;
2591025867 a_base_class_ptr bcp;
2591125868 a_byte_count n_args = 1, n_params = 1;
2591225869 a_byte_count *arg_size;
2591325870 a_byte *arg_ptrs, **p_arg_ptr, *this_bytes, *arg_sizes;
2591425871 an_alloc_seq_number alloc_seq_number;
2591525872 a_type_ptr class_type = parent_class_of(callee);
2591625873 unsigned long up_front_cost;
25917- /* Don't attempt to interpret a non-constexpr function. The flag
25918- scope->is_constexpr_routine is set at the end of a constexpr function
25919- definition, so this also prevents the interpretation of a function that
25920- is not fully parsed (e.g., requested due to a recursive call in a
25921- constexpr function). */
25922- if (!callee_scope->is_constexpr_routine) {
25923- do_constexpr_fail(result);
25924- info_with_pos_sym(ec_constexpr_call_not_interpretable, pos,
25925- symbol_for(callee), ips);
25926- goto done;
25927- } /* if */
25928- if (class_type->variant.class_struct_union.any_virtual_base_classes) {
25929- do_constexpr_fail(result);
25930- info_with_pos_type(ec_constexpr_object_with_virtual_base, pos,
25931- class_type, ips);
25932- goto done;
25933- } /* if */
2593425874 /* Set up arguments, starting with "this" if applicable. */
2593525875 /* This process must happen in two phases. First, the arguments must be
2593625876 allocated and evaluated. Only then can we map parameter variables onto
@@ -25948,17 +25888,9 @@ compound statement of that handler.
2594825888 result = FALSE;
2594925889 goto done;
2595025890 } /* if */
25951- /* Count the parameters (including "this") to make sure there are enough
25952- arguments for the parameters. */
25953- for (param = params; param != NULL; param = param->next) {
25954- n_params += 1;
25955- } /* if */
25956- if (n_args < n_params) {
25957- info_with_pos(ec_too_few_arguments, pos, ips);
25958- do_constexpr_fail(result);
25959- goto done;
25960- } /* if */
25961- /* Phase 1: Allocate and evaluate the arguments. */
25891+ /* Phase 1: Allocate and evaluate the arguments. That precedes the checks
25892+ of the constructor below: If the evaluation of an argument exits by
25893+ throwing an exception, the constructor is not invoked. */
2596225894 /* The "+1" below is to account for the "this" pointer (handled later). */
2596325895 p_arg_ptr = (a_byte**)arg_ptrs+1;
2596425896 arg_size = (a_byte_count*)arg_sizes;
@@ -25967,13 +25899,16 @@ compound statement of that handler.
2596725899 /* The first non-this argument is implicit (i.e., not represented in
2596825900 the IL). Since it always corresponds to the reference parameter of
2596925901 a copy/move constructor, we know it is a constexpr address. */
25902+ a_type_ptr routine_type = skip_typerefs(callee->type);
25903+ a_type_ptr param_type =
25904+ rout_type_supp(routine_type)->param_type_list->type;
2597025905 a_byte_count n_bytes = sizeof(a_constexpr_address);
2597125906 a_byte *arg_bytes;
2597225907 do_host_alignment(&n_bytes);
2597325908 *arg_size = n_bytes;
2597425909 arg_size += 1;
2597525910 n_bytes += sizeof(a_var_postfix);
25976- if (!alloc_complete_object(ips, n_bytes, params->type , arg_bytes)) {
25911+ if (!alloc_complete_object(ips, n_bytes, param_type , arg_bytes)) {
2597725912 goto done;
2597825913 } /* if */
2597925914 *(a_constexpr_address*)arg_bytes = *implied_src;
@@ -26036,6 +25971,79 @@ compound statement of that handler.
2603625971 goto done;
2603725972 } /* if */
2603825973 } /* for */
25974+ /* Check that the constructor can be interpreted, and retrieve its routine
25975+ scope. */
25976+ if (!callee->is_constexpr) {
25977+ info_with_pos_sym(ec_constexpr_call_to_nonconstexpr_function,
25978+ pos, symbol_for(callee), ips);
25979+ do_constexpr_fail(result);
25980+ goto done;
25981+ } /* if */
25982+ if (!callee->defined) {
25983+ if (has_routine_definition_from_module(callee)) {
25984+ /* The definition was stored in a module file. */
25985+ if (!load_routine_definition_from_module(callee)) {
25986+ ips->input_error = TRUE;
25987+ do_constexpr_fail(result);
25988+ } /* if */
25989+ } else if ((callee->is_inheriting_ctor || callee->compiler_generated) &&
25990+ !callee->is_deleted) {
25991+ force_definition_of_compiler_generated_routine(callee);
25992+ } else {
25993+ set_instance_required(symbol_for(callee), TRUE, SIR_CONSTANT_CONTEXT);
25994+ } /* if */
25995+ } /* if */
25996+ if (callee->function_def_number == NULL_function_def_number) {
25997+ info_with_pos_sym(ec_constexpr_function_undefined, pos,
25998+ symbol_for(callee), ips);
25999+ do_constexpr_fail(result);
26000+ if (callee->is_deleted && ips->is_constant_evaluated) {
26001+ /* An error has presumably been issued earlier (use of a deleted
26002+ function). Treat this as an input error to avoid extraneous
26003+ diagnostics. */
26004+ expect_error();
26005+ ips->input_error = TRUE;
26006+ } /* if */
26007+ goto done;
26008+ } else if (callee->is_prototype_instantiation) {
26009+ info_with_pos_sym(ec_constexpr_call_not_interpretable, pos,
26010+ symbol_for(callee), ips);
26011+ do_constexpr_fail(result);
26012+ goto done;
26013+ } else if (cost_exceeded(ips)) {
26014+ report_excessive_cost(ips);
26015+ do_constexpr_fail(result);
26016+ goto done;
26017+ } /* if */
26018+ callee_scope = scope_for_routine(callee);
26019+ params = callee_scope->variant.routine.parameters;
26020+ /* Don't attempt to interpret a non-constexpr function. The flag
26021+ scope->is_constexpr_routine is set at the end of a constexpr function
26022+ definition, so this also prevents the interpretation of a function that
26023+ is not fully parsed (e.g., requested due to a recursive call in a
26024+ constexpr function). */
26025+ if (!callee_scope->is_constexpr_routine) {
26026+ do_constexpr_fail(result);
26027+ info_with_pos_sym(ec_constexpr_call_not_interpretable, pos,
26028+ symbol_for(callee), ips);
26029+ goto done;
26030+ } /* if */
26031+ if (class_type->variant.class_struct_union.any_virtual_base_classes) {
26032+ do_constexpr_fail(result);
26033+ info_with_pos_type(ec_constexpr_object_with_virtual_base, pos,
26034+ class_type, ips);
26035+ goto done;
26036+ } /* if */
26037+ /* Count the parameters (including "this") to make sure there are enough
26038+ arguments for the parameters. */
26039+ for (param = params; param != NULL; param = param->next) {
26040+ n_params += 1;
26041+ } /* if */
26042+ if (n_args < n_params) {
26043+ info_with_pos(ec_too_few_arguments, pos, ips);
26044+ do_constexpr_fail(result);
26045+ goto done;
26046+ } /* if */
2603926047 /* Phase 2: Map the parameters to the arguments. */
2604026048 /* Associate with the parameter variables a new allocation number. For
2604126049 ordinary calls, we just use the allocation number about to be created
0 commit comments