From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed 1/4] c++: copy location to AGGR_INIT_EXPR
Date: Wed, 13 Dec 2023 11:47:37 -0500 [thread overview]
Message-ID: <20231213164740.1591535-1-jason@redhat.com> (raw)
In-Reply-To: <a24c149c-cf86-4ded-ad7a-7a8b585f6b2b@redhat.com>
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
When building an AGGR_INIT_EXPR from a CALL_EXPR, we shouldn't lose location
information.
gcc/cp/ChangeLog:
* tree.cc (build_aggr_init_expr): Copy EXPR_LOCATION.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/constexpr-nsdmi7b.C: Adjust line.
* g++.dg/template/copy1.C: Likewise.
---
gcc/cp/tree.cc | 1 +
gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C | 4 ++--
gcc/testsuite/g++.dg/template/copy1.C | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index da4d5c51f07..c4e41fd7b5c 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -689,6 +689,7 @@ build_aggr_init_expr (tree type, tree init)
CALL_EXPR_OPERATOR_SYNTAX (rval) = CALL_EXPR_OPERATOR_SYNTAX (init);
CALL_EXPR_ORDERED_ARGS (rval) = CALL_EXPR_ORDERED_ARGS (init);
CALL_EXPR_REVERSE_ARGS (rval) = CALL_EXPR_REVERSE_ARGS (init);
+ SET_EXPR_LOCATION (rval, EXPR_LOCATION (init));
}
else
rval = init;
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C
index a410e482664..586ee54124c 100644
--- a/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C
@@ -20,8 +20,8 @@ bar()
{
A a = foo();
a.p->n = 5;
- return a;
-} // { dg-error "non-.constexpr." "" { target c++20_down } }
+ return a; // { dg-error "non-.constexpr." "" { target c++20_down } }
+}
constexpr int
baz()
diff --git a/gcc/testsuite/g++.dg/template/copy1.C b/gcc/testsuite/g++.dg/template/copy1.C
index eacd9e2c025..7e0a3805a77 100644
--- a/gcc/testsuite/g++.dg/template/copy1.C
+++ b/gcc/testsuite/g++.dg/template/copy1.C
@@ -6,10 +6,10 @@
struct A
{
- // { dg-error "reference" "" { target c++14_down } .+1 }
A(A&); // { dg-message "A::A" "" { target c++14_down } }
template <class T> A(T); // { dg-message "A::A" "" { target c++14_down } }
};
+// { dg-error "reference" "" { target c++14_down } .+1 }
A a = 0; // { dg-error "no match" "" { target c++14_down } }
base-commit: d2b269ce30d77dbfc6c28c75887c330d4698b132
--
2.39.3
next prev parent reply other threads:[~2023-12-13 16:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 1:18 [PATCH] c++: End lifetime of objects in constexpr after destructor call [PR71093] Nathaniel Shead
2023-11-03 1:34 ` Nathaniel Shead
2023-11-27 11:08 ` Nathaniel Shead
2023-12-09 20:12 ` Jason Merrill
2023-12-10 10:22 ` Richard Biener
2023-12-10 11:21 ` Alexander Monakov
2023-12-10 15:58 ` Richard Biener
2023-12-10 18:34 ` Jason Merrill
2023-12-11 8:02 ` Richard Biener
2023-12-11 19:12 ` Jason Merrill
2023-12-11 19:17 ` Richard Biener
2023-12-11 19:21 ` Marek Polacek
2023-12-11 22:00 ` Jason Merrill
2023-12-11 22:22 ` Marek Polacek
2023-12-11 23:03 ` Jakub Jelinek
2023-12-12 11:13 ` Alexander Monakov
2023-12-12 11:15 ` Jakub Jelinek
2023-12-12 15:24 ` Jason Merrill
2023-12-12 17:50 ` Jason Merrill
2023-12-13 4:40 ` Jason Merrill
2023-12-13 16:47 ` Jason Merrill [this message]
2023-12-13 16:47 ` [pushed 2/4] c++: constant direct-initialization [PR108243] Jason Merrill
2023-12-13 16:47 ` [pushed 3/4] c++: fix in-charge parm in constexpr Jason Merrill
2023-12-13 16:47 ` [pushed 4/4] c++: End lifetime of objects in constexpr after destructor call [PR71093] Jason Merrill
2023-12-13 18:05 ` [pushed 1/4] c++: copy location to AGGR_INIT_EXPR Patrick Palka
2023-12-13 20:06 ` [pushed] c++: TARGET_EXPR location in default arg [PR96997] Jason Merrill
2023-12-14 0:00 ` [pushed 1/4] c++: copy location to AGGR_INIT_EXPR Marek Polacek
2023-12-14 1:38 ` Jason Merrill
2023-12-14 14:25 ` Marek Polacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231213164740.1591535-1-jason@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).