diff mbox

Improve error message for vector conversion

Message ID alpine.DEB.2.02.1505151152430.19595@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse May 15, 2015, 9:59 a.m. UTC
Hello,

this patch was regtested on ppc64le-redhat-linux.

2015-05-15  Marc Glisse  <marc.glisse@inria.fr>

gcc/
 	* convert.c (convert_to_integer, convert_to_vector): Include the
 	types in the error message.
gcc/testsuite/
 	* gcc.dg/simd-1.c: Update to the new message.

Comments

Jeff Law May 19, 2015, 6:49 a.m. UTC | #1
On 05/15/2015 03:59 AM, Marc Glisse wrote:
> Hello,
>
> this patch was regtested on ppc64le-redhat-linux.
>
> 2015-05-15  Marc Glisse  <marc.glisse@inria.fr>
>
> gcc/
>      * convert.c (convert_to_integer, convert_to_vector): Include the
>      types in the error message.
> gcc/testsuite/
>      * gcc.dg/simd-1.c: Update to the new message.
OK.
jeff
diff mbox

Patch

Index: gcc/convert.c
===================================================================
--- gcc/convert.c	(revision 223214)
+++ gcc/convert.c	(working copy)
@@ -913,21 +913,23 @@  convert_to_integer (tree type, tree expr
       return build1 (FIXED_CONVERT_EXPR, type, expr);
 
     case COMPLEX_TYPE:
       return convert (type,
 		      fold_build1 (REALPART_EXPR,
 				   TREE_TYPE (TREE_TYPE (expr)), expr));
 
     case VECTOR_TYPE:
       if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
 	{
-	  error ("can%'t convert between vector values of different size");
+	  error ("can%'t convert a vector of type %qT"
+		 " to type %qT which has different size",
+		 TREE_TYPE (expr), type);
 	  return error_mark_node;
 	}
       return build1 (VIEW_CONVERT_EXPR, type, expr);
 
     default:
       error ("aggregate value used where an integer was expected");
       return convert (type, integer_zero_node);
     }
 }
 
@@ -997,21 +999,23 @@  convert_to_complex (tree type, tree expr
 
 tree
 convert_to_vector (tree type, tree expr)
 {
   switch (TREE_CODE (TREE_TYPE (expr)))
     {
     case INTEGER_TYPE:
     case VECTOR_TYPE:
       if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
 	{
-	  error ("can%'t convert between vector values of different size");
+	  error ("can%'t convert a value of type %qT"
+		 " to vector type %qT which has different size",
+		 TREE_TYPE (expr), type);
 	  return error_mark_node;
 	}
       return build1 (VIEW_CONVERT_EXPR, type, expr);
 
     default:
       error ("can%'t convert value to a vector");
       return error_mark_node;
     }
 }
 
Index: gcc/testsuite/gcc.dg/simd-1.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-1.c	(revision 223214)
+++ gcc/testsuite/gcc.dg/simd-1.c	(working copy)
@@ -38,21 +38,21 @@  hanneke ()
   /* Casted different signed SIMD assignment.  */
   f = (uv4si) a;
 
   /* Assignment between scalar and SIMD of different size.  */
   foo = a; /* { dg-error "incompatible types when assigning" } */
 
   /* Casted assignment between scalar and SIMD of same size.  */
   foo = (typeof (foo)) foo2;
 
   /* Casted assignment between scalar and SIMD of different size.  */
-  foo1 = (typeof (foo1)) foo2; /* { dg-error "can't convert between vector values of different size" } */
+  foo1 = (typeof (foo1)) foo2; /* { dg-error "can't convert a vector of type" } */
 
   /* Operators on compatible SIMD types.  */
   a += b + b;
   a -= b;
   a *= b;
   a /= b;
   a = -b;
 
   /* Operators on incompatible SIMD types.  */
   a = b + c; /* { dg-error "invalid operands to binary +" } */