From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 002293858C50 for ; Tue, 4 Oct 2022 22:52:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 002293858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664923954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uYO4i0hudg2aUGpe0fWrXaGeJtAyWfXFgR8rSYisIVE=; b=aww5iiG4sE7g0HuzGHJnEr6dQS8f39NIfoGXMN3a4XFdypg2o01rF/j8lP/dVBHLIYgHbS 3U7P9JNKxj602uFQ83s/wNqPpjhJpNnyDDNygMS7Z5AGbSx1wRnFYxbor2inyzPLLZSEo/ V2MlXMjs30ZEAqassOC9zCwcKPjxlDA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-523-a4oqo4qeO6OwaLRBLvMzpQ-1; Tue, 04 Oct 2022 18:52:33 -0400 X-MC-Unique: a4oqo4qeO6OwaLRBLvMzpQ-1 Received: by mail-qk1-f200.google.com with SMTP id h8-20020a05620a284800b006b5c98f09fbso13056572qkp.21 for ; Tue, 04 Oct 2022 15:52:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=uYO4i0hudg2aUGpe0fWrXaGeJtAyWfXFgR8rSYisIVE=; b=zFDGs8PK+ICHW5Riu4c8w/ulciOXqy1K9fDbMjdtQxwyzNBGNWGk/ZgeJj/Y3s+tTD IGVKQbkre0W1GwTo6IKwqWB+bUtJMD7tM2e8HCulClRAOZaz9r1t65hcdqcUjKCHuW7P pLixmlb4xDq4MCibQc2PP7xtzw5Se5NmTf5AWMA3za3Ogwhro9+JIffDYjPbzCz7yYjL J9qWs/+l5wJiXu/Z/f1MYvM0sIo84pO83fTSuLD9oklhwHPfQ8VB1qmZLC1dA3Cz9Q/C UEMJkFZnlL76VEXuenaN10jfPXvqa15kQTt2wUZfMbAeEOqfulVXzDcfa/Pw4ezXnyos 3ztw== X-Gm-Message-State: ACrzQf2Jd3bFge4nJu2ZrOz+SgRschpwlt6TryV/FfSIOTSQBDvlR9tu b/mnr4h63nFXB/BdUMd0L/4sXfjXSKToGl5Yyn+F8rSVJuK4Qk8yBqsuilq7nt48X145J1qs4mI Erd9Co0Um7TeynasLX028C+gn2RYsDSEN3Wp27hnCiswjEkmC32wl16HgpVkNKrUeyQ== X-Received: by 2002:ac8:5750:0:b0:35c:cb1b:2639 with SMTP id 16-20020ac85750000000b0035ccb1b2639mr21800729qtx.183.1664923952845; Tue, 04 Oct 2022 15:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ffY+jC6jCBlhF0JAnqSI1BKjUyna/EMv2D0JGrwGbtut4XGj5tHWrTqr++YpcapdsyK69qA== X-Received: by 2002:ac8:5750:0:b0:35c:cb1b:2639 with SMTP id 16-20020ac85750000000b0035ccb1b2639mr21800715qtx.183.1664923952482; Tue, 04 Oct 2022 15:52:32 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id k4-20020ac84784000000b0033b30e8e7a5sm12354026qtq.58.2022.10.04.15.52.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 15:52:31 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: fix debug info for array temporary [PR107154] Date: Tue, 4 Oct 2022 18:52:29 -0400 Message-Id: <20221004225229.3104706-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 List-Id: Tested x86_64-pc-linux-gnu, applying to trunk. -- >8 -- In the testcase the elaboration of the array init that happens at genericize time was getting the location info for the end of the function; fixed by doing the expansion at the location of the original expression. PR c++/107154 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_genericize_init_expr): Use iloc_sentinel. (cp_genericize_target_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/debug/dwarf2/lineno-array1.C: New test. --- gcc/cp/cp-gimplify.cc | 2 ++ .../g++.dg/debug/dwarf2/lineno-array1.C | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index cca3b9fea33..404a7699a72 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -920,6 +920,7 @@ cp_genericize_init (tree *replace, tree from, tree to) static void cp_genericize_init_expr (tree *stmt_p) { + iloc_sentinel ils = EXPR_LOCATION (*stmt_p); tree to = TREE_OPERAND (*stmt_p, 0); tree from = TREE_OPERAND (*stmt_p, 1); if (SIMPLE_TARGET_EXPR_P (from) @@ -935,6 +936,7 @@ cp_genericize_init_expr (tree *stmt_p) static void cp_genericize_target_expr (tree *stmt_p) { + iloc_sentinel ils = EXPR_LOCATION (*stmt_p); tree slot = TARGET_EXPR_SLOT (*stmt_p); cp_genericize_init (&TARGET_EXPR_INITIAL (*stmt_p), TARGET_EXPR_INITIAL (*stmt_p), slot); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C b/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C new file mode 100644 index 00000000000..befac5f04b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C @@ -0,0 +1,25 @@ +// PR c++/107154 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-gno-as-loc-support -dA" } +// Test that we emit debug info exactly once for the last line. +// { dg-final { scan-assembler-times {:25:1} 1 } } + +bool dummy; + +struct S { + const char *p; + S(const char *p): p(p) {} + ~S() { dummy = true; } +}; + +using Sar = S[]; + +struct X { + X(Sar&&) { } +}; + +int main() +{ + X x(Sar{"", ""}); + return 0; +} base-commit: 49c3e9dfc5e23a335f4057efffbff2273e3c4631 -- 2.31.1