[C++] Improve grok_array_decl location
diff mbox series

Message ID ab1e0a55-8e34-d4e4-a1ee-6901c5ba60f2@oracle.com
State New
Headers show
Series
  • [C++] Improve grok_array_decl location
Related show

Commit Message

Paolo Carlini Aug. 13, 2019, 9:22 a.m. UTC
Hi,

for this error message about the types involved in array subscripting I 
think we can exploit the available location argument and point to the 
open square bracket instead of simply using input_location. Tested 
x86_64-linux.

Thanks, Paolo Carlini.

////////////////////////
/cp
2019-08-13  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl2.c (grok_array_decl): Use the location of the open square
	bracket in error message about invalid types.

/testsuite
2019-08-13  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/conversion/simd4.C: Test locations.

Comments

Jason Merrill Aug. 13, 2019, 3:05 p.m. UTC | #1
On 8/13/19 5:22 AM, Paolo Carlini wrote:
> Hi,
> 
> for this error message about the types involved in array subscripting I 
> think we can exploit the available location argument and point to the 
> open square bracket instead of simply using input_location. Tested 
> x86_64-linux.
> 
> Thanks, Paolo Carlini.
> 
> ////////////////////////
> 

OK.

Jason

Patch
diff mbox series

Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 274330)
+++ cp/decl2.c	(working copy)
@@ -434,8 +434,8 @@  grok_array_decl (location_t loc, tree array_expr,
 	array_expr = p2, index_exp = i1;
       else
 	{
-	  error ("invalid types %<%T[%T]%> for array subscript",
-		 type, TREE_TYPE (index_exp));
+	  error_at (loc, "invalid types %<%T[%T]%> for array subscript",
+		    type, TREE_TYPE (index_exp));
 	  return error_mark_node;
 	}
 
Index: testsuite/g++.dg/conversion/simd4.C
===================================================================
--- testsuite/g++.dg/conversion/simd4.C	(revision 274330)
+++ testsuite/g++.dg/conversion/simd4.C	(working copy)
@@ -12,13 +12,13 @@  void
 foo ()
 {
   b[t];
-  b[u];		// { dg-error "invalid types" }
-  b[v];		// { dg-error "invalid types" }
-  b[w];		// { dg-error "invalid types" }
+  b[u];		// { dg-error "4:invalid types" }
+  b[v];		// { dg-error "4:invalid types" }
+  b[w];		// { dg-error "4:invalid types" }
   t[b];
-  u[b];		// { dg-error "invalid types" }
-  v[b];		// { dg-error "invalid types" }
-  w[b];		// { dg-error "invalid types" }
+  u[b];		// { dg-error "4:invalid types" }
+  v[b];		// { dg-error "4:invalid types" }
+  w[b];		// { dg-error "4:invalid types" }
   new int[t];
   new int[u];	// { dg-error "new-declarator must have integral" }
   new int[v];	// { dg-error "new-declarator must have integral" }