From: Simon Martin Date: Wed, 2 Oct 2024 13:32:37 +0000 (+0200) Subject: c++: Fix regression introduced by r15-3796 [PR116722] X-Git-Tag: basepoints/gcc-16~5527 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a528386571fffbb41703a238aee950043af3f3c;p=thirdparty%2Fgcc.git c++: Fix regression introduced by r15-3796 [PR116722] Jason pointed out that the fix I made for PR116722 via r15-3796 introduces a regression when running constexpr-dynamic10.C with -fimplicit-constexpr. The problem is that my change makes us leave cxx_eval_call_expression early, and bypass the call to cxx_eval_thunk_call (through a recursive call to cxx_eval_call_expression) that used to emit an error for that testcase with -fimplicit-constexpr. This patch emits the error if !ctx->quiet before bailing out because the {con,de}structor belongs to a class with virtual bases. PR c++/116722 gcc/cp/ChangeLog: * constexpr.cc (cxx_bind_parameters_in_call): When !ctx->quiet, emit error before bailing out due to a call to {con,de}structor for a class with virtual bases. --- diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 5c6696740fc..4e4df94f420 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -1867,6 +1867,12 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t, tree fun, with virtual bases. */ if (DECL_HAS_IN_CHARGE_PARM_P (fun) || DECL_HAS_VTT_PARM_P (fun)) { + if (!ctx->quiet) + { + error_at (cp_expr_loc_or_input_loc (t), + "call to non-% function %qD", fun); + explain_invalid_constexpr_fn (fun); + } *non_constant_p = true; return binds; }