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: 154053 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4038932vqb; Tue, 17 Oct 2023 03:36:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLz7JH0NvwfPe+osOUDh2BNIw8RkscM/UHqMbm+zlyKbH46sKEDD05NFv5DLXP7uSc7EzR X-Received: by 2002:a05:620a:17a1:b0:76c:ecef:28c with SMTP id ay33-20020a05620a17a100b0076cecef028cmr2247097qkb.57.1697538963162; Tue, 17 Oct 2023 03:36:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697538963; cv=pass; d=google.com; s=arc-20160816; b=w/nPP6N8S8DI6rTdtX9dlxKHnvkhCpe6318+9TL6vmTaXXXJ7YNQpSx5f9RAaAHx+s KuzaMh6c7CEU3MHxzppYe1Dwmngxzvlg2Pefw3NOPBo8niHOxYwRoqt8TsieyB8Bc8Eo 04w6FMj9kK1ojk+d2MRQC+CdHRF84RdtkKGt9hkuq+p80cDpGondNakmCYnfHI2MZau6 rBainHcD/PwxTlyNTA6Rcog/7KsnnXD1KY5DewLS6CIhhvOI1QO8f91J0FoLB8TlkqWk EvU6sR8rJbmLXKQNXnd++9L8NRcXVEk4AKQY4lfXgL3zMxbPByzLlvtQb9ELsc1UaTIp gMBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:subject:cc:to:from:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=/rsgkbJmCez37pli1Eso894e3rCk2sp14FYtk8yvS1s=; fh=9hxfB3H4KTpSOFwvxn2SUwjjMAoolGu3rWL3nsW8Su4=; b=bVhL6Q0nyhtzNTJpE7Q1YqTgm8mwEaGgbZpLnRPdfX9N9RvhNUtv/LOnKwHks9NUwT zZfq2HO2xHvFT0sn/IdfsQVSZK4LH05gIfDNDcQPgWGamVKQuh4eNdQXWQ3aU/1q/0uo Ce4LAgP/yvPiVP7f+CxM6sJZwfbDhNHbkYG4Fo3TzT5UMvhOlEhelYszTTcr7yHYi2Qu 1SWVUL08jSfceiw4BQdvgeCB6kxRbgAl0e158Bk6qJEqMSXwS9VmpZ0tzgpVhsJh2s+/ +YQ3UAj4R5XQmetsCpJAFBREj/wa+TT6VvB1IAnKSvBdeW03I0fQjimqKar02OeIbbGx 09Yw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WH37FZs9; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w2-20020a05620a148200b00773a83f4736si792623qkj.585.2023.10.17.03.36.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 03:36:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WH37FZs9; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7EBE38582A3 for ; Tue, 17 Oct 2023 10:36:02 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779998615749895747 X-GMAIL-MSGID: 1779998615749895747 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)