My change in r10-7718 to make build_aggr_init_expr set EXPR_LOCATION
(mimicking build_target_expr) causes the debuginfo regression PR96997.
Given that this change is mostly independent of the rest of the commit,
and that the only fallout of reverting it is a less accurate error
message location in a testcase introduced in the same commit, it seems
the best way forward is to just revert this part of the commit.

Bootstrapped and regtested on x86_64-pc-linux-gnu, committed to trunk
under the "obvious" rule, backport to the 10 branch pending.

gcc/cp/ChangeLog:

        PR debug/96997
        PR c++/94034
        * tree.c (build_aggr_init_expr): Revert r10-7718 change.

gcc/testsuite/ChangeLog:

        PR debug/96997
        PR c++/94034
        * g++.dg/cpp1y/constexpr-nsdmi7b.C:  Adjust expected location of
        "call to non-'constexpr' function" error message.
---
 gcc/cp/tree.c                                  | 3 ---
 gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C | 4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index e6ced274959..3c469750e9d 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -674,9 +674,6 @@ build_aggr_init_expr (tree type, tree init)
   else
     rval = init;
 
-  if (location_t loc = EXPR_LOCATION (init))
-    SET_EXPR_LOCATION (rval, loc);
-
   return rval;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C 
b/gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi7b.C
index 86d8ab4e759..ec10ddd2be8 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." }
-}
+  return a;
+} // { dg-error "non-.constexpr." }
 
 constexpr int
 baz()
-- 
2.30.1.489.g328c109303

Reply via email to