c++: Give more expressions locations.
authorJason Merrill <jason@redhat.com>
Tue, 24 Mar 2020 22:25:17 +0000 (18:25 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 24 Mar 2020 22:25:17 +0000 (18:25 -0400)
In the testcase for PR94186, we have a SCOPE_REF with no location even
though at one point it was in a cp_expr which had a location.  So let's make
the cp_expr constructor that takes a location apply it to the expression
when possible.

gcc/cp/ChangeLog
2020-03-24  Jason Merrill  <jason@redhat.com>

* cp-tree.h (cp_expr): When constructing from an expr and a
location, call protected_set_expr_location.

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/testsuite/g++.dg/ext/stmtexpr15.C
gcc/testsuite/g++.dg/parse/error26.C
gcc/testsuite/g++.dg/warn/Wnoexcept1.C

index 59db03c..7ae4128 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-24  Jason Merrill  <jason@redhat.com>
+
+       * cp-tree.h (cp_expr): When constructing from an expr and a
+       location, call protected_set_expr_location.
+
 2020-03-23  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/93805
index 0783b31..4e1d0f1 100644 (file)
@@ -59,7 +59,10 @@ public:
     m_value (value), m_loc (cp_expr_location (m_value)) {}
 
   cp_expr (tree value, location_t loc):
-    m_value (value), m_loc (loc) {}
+    m_value (value), m_loc (loc)
+  {
+    protected_set_expr_location (value, loc);
+  }
 
   /* Implicit conversions to tree.  */
   operator tree () const { return m_value; }
index 10c4886..27406e1 100644 (file)
@@ -4,5 +4,5 @@
 void foo()
 {
   int x[({ return; })];                // { dg-error "could not convert" }
-// { dg-error "12:size of array .x. has non-integral" "" { target *-*-* } .-1 }  
+// { dg-error "9:size of array .x. has non-integral" "" { target *-*-* } .-1 }  
 }
index 95f2991..4005fd5 100644 (file)
@@ -4,7 +4,7 @@
 void foo()
 {
   if (({int c[2];})) ; // { dg-error "7:ISO C.. forbids" "7" }
-  // { dg-error "17:could not convert" "17" { target *-*-* } .-1 }
+  // { dg-error "7:could not convert" "17" { target *-*-* } .-1 }
 }
 
 void bar()
index 93210de..4fac367 100644 (file)
@@ -7,7 +7,7 @@
 // We expect a warning at the declaration of construct2, since Automatic2 is
 // defined below; we don't expect one for construct1, because Automatic1 is
 // defined in the fake system header.
-// { dg-warning "noexcept-expression" "" { target *-*-* } 15 }
+// { dg-warning "noexcept-expression" "" { target *-*-* } 16 }
 
 class Automatic2 {
 public: