diff mbox series

Don't ICE on vectors of enums (PR 87286)

Message ID 87k1mwwodj.fsf@arm.com
State New
Headers show
Series Don't ICE on vectors of enums (PR 87286) | expand

Commit Message

Richard Sandiford Oct. 5, 2018, 12:48 p.m. UTC
We've traditionally allowed vectors of enums (not sure if that's
deliberate) but vector_types_compatible_elements_p checked for
INTEGER_TYPE rather than INTEGRAL_TYPE_P.

Tested on aarch64-linux-gnu.  OK to install?

Richard


2018-10-05  Richard Sandiford  <richard.sandiford@arm.com>

gcc/c-family/
	PR c/87286
	* c-common.c (vector_types_compatible_elements_p): Use
	INTEGRAL_TYPE_P instead of checking only for INTEGER_TYPE.

gcc/testsuite/
	PR c/87286
	* gcc.dg/pr87286.c: New test.

Comments

Richard Biener Oct. 5, 2018, 4:23 p.m. UTC | #1
On October 5, 2018 2:48:24 PM GMT+02:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>We've traditionally allowed vectors of enums (not sure if that's
>deliberate) but vector_types_compatible_elements_p checked for
>INTEGER_TYPE rather than INTEGRAL_TYPE_P.
>
>Tested on aarch64-linux-gnu.  OK to install?

OK. 

Richard. 

>Richard
>
>
>2018-10-05  Richard Sandiford  <richard.sandiford@arm.com>
>
>gcc/c-family/
>	PR c/87286
>	* c-common.c (vector_types_compatible_elements_p): Use
>	INTEGRAL_TYPE_P instead of checking only for INTEGER_TYPE.
>
>gcc/testsuite/
>	PR c/87286
>	* gcc.dg/pr87286.c: New test.
>
>Index: gcc/c-family/c-common.c
>===================================================================
>--- gcc/c-family/c-common.c	2018-10-05 13:46:08.287811117 +0100
>+++ gcc/c-family/c-common.c	2018-10-05 13:47:08.291325001 +0100
>@@ -7465,8 +7465,11 @@ vector_types_compatible_elements_p (tree
> 
>   enum tree_code c1 = TREE_CODE (t1), c2 = TREE_CODE (t2);
> 
>-  gcc_assert ((c1 == INTEGER_TYPE || c1 == REAL_TYPE || c1 ==
>FIXED_POINT_TYPE)
>-	      && (c2 == INTEGER_TYPE || c2 == REAL_TYPE
>+  gcc_assert ((INTEGRAL_TYPE_P (t1)
>+	       || c1 == REAL_TYPE
>+	       || c1 == FIXED_POINT_TYPE)
>+	      && (INTEGRAL_TYPE_P (t2)
>+		  || c2 == REAL_TYPE
> 		  || c2 == FIXED_POINT_TYPE));
> 
>   t1 = c_common_signed_type (t1);
>@@ -7476,7 +7479,7 @@ vector_types_compatible_elements_p (tree
>   if (t1 == t2)
>     return true;
>   if (opaque && c1 == c2
>-      && (c1 == INTEGER_TYPE || c1 == REAL_TYPE)
>+      && (INTEGRAL_TYPE_P (t1) || c1 == REAL_TYPE)
>       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
>     return true;
>   return false;
>Index: gcc/testsuite/gcc.dg/pr87286.c
>===================================================================
>--- /dev/null	2018-09-14 11:16:31.122530289 +0100
>+++ gcc/testsuite/gcc.dg/pr87286.c	2018-10-05 13:47:08.291325001 +0100
>@@ -0,0 +1,3 @@
>+enum foo { F };
>+typedef enum foo vec_foo __attribute__((vector_size (16)));
>+vec_foo add (vec_foo x, vec_foo y) { return x + y; }
Jakub Jelinek Oct. 10, 2018, 9:04 a.m. UTC | #2
On Fri, Oct 05, 2018 at 01:48:24PM +0100, Richard Sandiford wrote:
> We've traditionally allowed vectors of enums (not sure if that's
> deliberate) but vector_types_compatible_elements_p checked for
> INTEGER_TYPE rather than INTEGRAL_TYPE_P.
> 
> Tested on aarch64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2018-10-05  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/c-family/
> 	PR c/87286
> 	* c-common.c (vector_types_compatible_elements_p): Use
> 	INTEGRAL_TYPE_P instead of checking only for INTEGER_TYPE.
> 
> gcc/testsuite/
> 	PR c/87286
> 	* gcc.dg/pr87286.c: New test.

This testcase fails on i686-linux (unless configured to default to -msse2):
Executing on host: /home/jakub/src/gcc/obj27/gcc/xgcc -B/home/jakub/src/gcc/obj27/gcc/ /home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c    -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-color=never    -ansi -pedantic-errors -S -o pr87286.s    (timeout = 300)
spawn -ignore SIGHUP /home/jakub/src/gcc/obj27/gcc/xgcc -B/home/jakub/src/gcc/obj27/gcc/ /home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-color=never -ansi -pedantic-errors -S -o pr87286.s
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c: In function 'add':
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c:3:1: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c:3:9: note: The ABI for passing parameters with 16-byte alignment has changed in GCC 4.6
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c:3:9: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]
FAIL: gcc.dg/pr87286.c (test for excess errors)
Excess errors:
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c:3:1: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/pr87286.c:3:9: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]

Fixed thusly, committed as obvious:

2018-10-10  Jakub Jelinek  <jakub@redhat.com>

	PR c/87286
	* gcc.dg/pr87286.c: Add -Wno-psabi to dg-options.

--- gcc/testsuite/gcc.dg/pr87286.c.jj	2018-10-08 15:18:28.923990456 +0200
+++ gcc/testsuite/gcc.dg/pr87286.c	2018-10-10 10:59:15.111698976 +0200
@@ -1,3 +1,4 @@
+/* { dg-options "-Wno-psabi" } */
 enum foo { F };
 typedef enum foo vec_foo __attribute__((vector_size (16)));
 vec_foo add (vec_foo x, vec_foo y) { return x + y; }


	Jakub
diff mbox series

Patch

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	2018-10-05 13:46:08.287811117 +0100
+++ gcc/c-family/c-common.c	2018-10-05 13:47:08.291325001 +0100
@@ -7465,8 +7465,11 @@  vector_types_compatible_elements_p (tree
 
   enum tree_code c1 = TREE_CODE (t1), c2 = TREE_CODE (t2);
 
-  gcc_assert ((c1 == INTEGER_TYPE || c1 == REAL_TYPE || c1 == FIXED_POINT_TYPE)
-	      && (c2 == INTEGER_TYPE || c2 == REAL_TYPE
+  gcc_assert ((INTEGRAL_TYPE_P (t1)
+	       || c1 == REAL_TYPE
+	       || c1 == FIXED_POINT_TYPE)
+	      && (INTEGRAL_TYPE_P (t2)
+		  || c2 == REAL_TYPE
 		  || c2 == FIXED_POINT_TYPE));
 
   t1 = c_common_signed_type (t1);
@@ -7476,7 +7479,7 @@  vector_types_compatible_elements_p (tree
   if (t1 == t2)
     return true;
   if (opaque && c1 == c2
-      && (c1 == INTEGER_TYPE || c1 == REAL_TYPE)
+      && (INTEGRAL_TYPE_P (t1) || c1 == REAL_TYPE)
       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
     return true;
   return false;
Index: gcc/testsuite/gcc.dg/pr87286.c
===================================================================
--- /dev/null	2018-09-14 11:16:31.122530289 +0100
+++ gcc/testsuite/gcc.dg/pr87286.c	2018-10-05 13:47:08.291325001 +0100
@@ -0,0 +1,3 @@ 
+enum foo { F };
+typedef enum foo vec_foo __attribute__((vector_size (16)));
+vec_foo add (vec_foo x, vec_foo y) { return x + y; }