From patchwork Tue Oct 17 10:35:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1849925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WH37FZs9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S8r3s0JCGz20Pd for ; Tue, 17 Oct 2023 21:35:52 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB0A83858418 for ; Tue, 17 Oct 2023 10:35:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 3F0B33858418 for ; Tue, 17 Oct 2023 10:35:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F0B33858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3F0B33858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697538939; cv=none; b=wPY2s3z7G47XDA77KJMGAleIYriTnqnwlDKDPbsO8MeZUll7KrVL9aQ6LPj7Q84pfgJq7L22JH5GsKUG7grm2ttU/irDMCYyiH4LB6ks8hW4kYJsGQnMYlni0zPUM7RR89q6z4G4qLBCV2uUpf/urCJs7VUEbSVxs7DT/0GOKAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697538939; c=relaxed/simple; bh=+m0knWojA+7JO8tVLRq2Rswpp5wMm30zimLUqfHjagg=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=VduiTVWit7jjKNKGfxQ9cPmMQiLauGLTAq5YSY7lEL1S6Xx4dfBW4UmcIXxL8RDYyhNhpqmyqxAvgyt+yleT8I5rWcmocVgPkh2dlde5i1E9fGFDIBSmObEr5vmt3NTe/zahUJGnPxnsf4hUi+RH5SAKNBb7KvozzCCx7txgQ5w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdf4752c3cso32691405ad.2 for ; Tue, 17 Oct 2023 03:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697538928; x=1698143728; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=/rsgkbJmCez37pli1Eso894e3rCk2sp14FYtk8yvS1s=; b=WH37FZs9GHWJQAhruIDMgdD+dwvJwljIBkRmzpqW6GztYPv04UMyGXdhEcs+V912hf xTE0gwV+xd43Fz0Qumvc2xU0t1lDDQTbuz70WbNpro6dXEMkxzThl1QVyiYEg43+/zHO lAawQ+hnSTTWkxt6beIphftPC/4GQN7tkIrVbPvlMG6eYvZ7SbOi1Csf2JHwvKoOS+gE aPaa0Fc5B6uQyU3DB8fzR5n9XiOBpEnFcqSXa8xZoUy+OHa0ax6o0IcwMoL+P6HTEkdI oapo/yH9X23wx+Oe1xLrFj76J4+83JKajdXXj7OkEweCZSPG9Oyb3Ob0U25fDbYI6dJk CrIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697538928; x=1698143728; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/rsgkbJmCez37pli1Eso894e3rCk2sp14FYtk8yvS1s=; b=R06OYmntNcti/i3e4QK5G2IufA/53dOaCom9pWQKGB+lIyMMxjZpiRMfAu4bCB40wW +X0Ve0TZ4iAcl2iuFFHvwFyMUGkhxTApmTYEm8IH4CQMgmVkvjvA4Jh1zknXvvH/9S+S c8hLFkcOoYTuc8CF/BQwDP46lriNMdjRaYLLwLaVoinGGeG62ugw2KxeXPs86X50W8LF yv0cYS6gyL6HxGgzyrvpqZ3d5BgHHYexeDYhi4NpjviVknW9wY+Mlb67LvVIbe96PlPQ XBJ3OC9mdXvgY1y0yOmSLCqP4GpRxqFf6hcz+FV+fcENEV6aUJX7h1IVU7BzE35VJYKx xDsg== X-Gm-Message-State: AOJu0YyPEU8qWoddYqqWHu4XuqZ9GdF1BsUic5tKNy0QF/g6Z+XjRGhU /tE5lMz63QK0QAU+I980To4HYnIURa8= X-Google-Smtp-Source: AGHT+IHoZbMM1Onml0I/xg4tSWeo3+TOMO/UfUV9lu1dng4Hc/CnklAf7LJtEZVdB6Taiy9Pj129Ug== X-Received: by 2002:a17:903:1207:b0:1c9:c920:6df3 with SMTP id l7-20020a170903120700b001c9c9206df3mr1914552plh.53.1697538927797; Tue, 17 Oct 2023 03:35:27 -0700 (PDT) Received: from Thaum. (124-150-88-161.tpgi.com.au. [124.150.88.161]) by smtp.gmail.com with ESMTPSA id y1-20020a170902ed4100b001c3267ae31bsm1173312plb.301.2023.10.17.03.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 03:35:26 -0700 (PDT) Message-ID: <652e636e.170a0220.9f5ea.3365@mx.google.com> X-Google-Original-Message-ID: Date: Tue, 17 Oct 2023 21:35:21 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Marek Polacek , Jason Merrill Subject: [PATCH] c++: Add missing auto_diagnostic_groups to constexpr.cc MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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 --- 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 % 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 % 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 % 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 % 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)