Message ID | 652e636e.170a0220.9f5ea.3365@mx.google.com |
---|---|
State | New |
Headers | show |
Series | c++: Add missing auto_diagnostic_groups to constexpr.cc | expand |
On Tue, Oct 17, 2023 at 09:35:21PM +1100, Nathaniel Shead wrote: > Marek pointed out in another patch of mine [1] that I was missing an > auto_diagnostic_group to correctly associate informative notes with > their errors in structured error outputs. This patch goes through > constexpr.cc to correct this in other locations which seem to have the > same issue. Thanks for the patch. I went through all of them and they all seem correct. So, LGTM, but can't approve. > [1]: https://gcc.gnu.org/pipermail/gcc-patches/2023-October/632653.html > > Bootstrapped and regtested on x86_64-pc-linux-gnu. > > -- >8 -- > > gcc/cp/ChangeLog: > > * constexpr.cc (cxx_eval_dynamic_cast_fn): Add missing > auto_diagnostic_group. > (cxx_eval_call_expression): Likewise. > (diag_array_subscript): Likewise. > (outside_lifetime_error): Likewise. > (potential_constant_expression_1): Likewise. > > Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> > --- > gcc/cp/constexpr.cc | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > index dde4fec4a44..7c8f2cc189d 100644 > --- a/gcc/cp/constexpr.cc > +++ b/gcc/cp/constexpr.cc > @@ -2437,6 +2437,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "reference %<dynamic_cast%> failed"); > inform (loc, "dynamic type %qT of its operand does " > "not have a base class of type %qT", > @@ -2492,6 +2493,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "reference %<dynamic_cast%> failed"); > inform (loc, "static type %qT of its operand is a " > "non-public base class of dynamic type %qT", > @@ -2524,6 +2526,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "reference %<dynamic_cast%> failed"); > inform (loc, "static type %qT of its operand is a non-public" > " base class of dynamic type %qT", objtype, mdtype); > @@ -2545,6 +2548,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "reference %<dynamic_cast%> failed"); > if (b_kind == bk_ambig) > inform (loc, "%qT is an ambiguous base class of dynamic " > @@ -2822,6 +2826,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "array deallocation of object " > "allocated with non-array " > "allocation"); > @@ -2844,6 +2849,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, > { > if (!ctx->quiet) > { > + auto_diagnostic_group d; > error_at (loc, "non-array deallocation of " > "object allocated with array " > "allocation"); > @@ -4193,6 +4199,7 @@ diag_array_subscript (location_t loc, const constexpr_ctx *ctx, tree array, tree > STRIP_ANY_LOCATION_WRAPPER (array); > if (DECL_P (array)) > { > + auto_diagnostic_group d; > if (TYPE_DOMAIN (arraytype)) > error_at (loc, "array subscript value %qE is outside the bounds " > "of array %qD of type %qT", sidx, array, arraytype); > @@ -5838,6 +5845,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, > static void > outside_lifetime_error (location_t loc, tree r) > { > + auto_diagnostic_group d; > if (DECL_NAME (r) == heap_deleted_identifier) > { > /* Provide a more accurate message for deleted variables. */ > @@ -9460,6 +9468,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > if (flags & tf_error) > { > tree cap = DECL_CAPTURED_VARIABLE (t); > + auto_diagnostic_group d; > if (constexpr_error (input_location, fundef_p, > "lambda capture of %qE is not a " > "constant expression", cap) > -- > 2.42.0 > Marek
On 10/17/23 12:34, Marek Polacek wrote: > On Tue, Oct 17, 2023 at 09:35:21PM +1100, Nathaniel Shead wrote: >> Marek pointed out in another patch of mine [1] that I was missing an >> auto_diagnostic_group to correctly associate informative notes with >> their errors in structured error outputs. This patch goes through >> constexpr.cc to correct this in other locations which seem to have the >> same issue. > > Thanks for the patch. I went through all of them and they all seem correct. > > So, LGTM, but can't approve. Thanks, I pushed it with a Reviewed-By of Marek. Jason
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index dde4fec4a44..7c8f2cc189d 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2437,6 +2437,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "dynamic type %qT of its operand does " "not have a base class of type %qT", @@ -2492,6 +2493,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "static type %qT of its operand is a " "non-public base class of dynamic type %qT", @@ -2524,6 +2526,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); inform (loc, "static type %qT of its operand is a non-public" " base class of dynamic type %qT", objtype, mdtype); @@ -2545,6 +2548,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "reference %<dynamic_cast%> failed"); if (b_kind == bk_ambig) inform (loc, "%qT is an ambiguous base class of dynamic " @@ -2822,6 +2826,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "array deallocation of object " "allocated with non-array " "allocation"); @@ -2844,6 +2849,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) { + auto_diagnostic_group d; error_at (loc, "non-array deallocation of " "object allocated with array " "allocation"); @@ -4193,6 +4199,7 @@ diag_array_subscript (location_t loc, const constexpr_ctx *ctx, tree array, tree STRIP_ANY_LOCATION_WRAPPER (array); if (DECL_P (array)) { + auto_diagnostic_group d; if (TYPE_DOMAIN (arraytype)) error_at (loc, "array subscript value %qE is outside the bounds " "of array %qD of type %qT", sidx, array, arraytype); @@ -5838,6 +5845,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, static void outside_lifetime_error (location_t loc, tree r) { + auto_diagnostic_group d; if (DECL_NAME (r) == heap_deleted_identifier) { /* Provide a more accurate message for deleted variables. */ @@ -9460,6 +9468,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (flags & tf_error) { tree cap = DECL_CAPTURED_VARIABLE (t); + auto_diagnostic_group d; if (constexpr_error (input_location, fundef_p, "lambda capture of %qE is not a " "constant expression", cap)
Marek pointed out in another patch of mine [1] that I was missing an auto_diagnostic_group to correctly associate informative notes with their errors in structured error outputs. This patch goes through constexpr.cc to correct this in other locations which seem to have the same issue. [1]: https://gcc.gnu.org/pipermail/gcc-patches/2023-October/632653.html Bootstrapped and regtested on x86_64-pc-linux-gnu. -- >8 -- gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_dynamic_cast_fn): Add missing auto_diagnostic_group. (cxx_eval_call_expression): Likewise. (diag_array_subscript): Likewise. (outside_lifetime_error): Likewise. (potential_constant_expression_1): Likewise. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> --- gcc/cp/constexpr.cc | 9 +++++++++ 1 file changed, 9 insertions(+)