Don't ICE on vectors of enums (PR 87286)
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 8 Oct 2018 08:16:13 +0000 (08:16 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 8 Oct 2018 08:16:13 +0000 (08:16 +0000)
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.

2018-10-08  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.

From-SVN: r264913

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr87286.c [new file with mode: 0644]

index b6ff1f783b32ed8f47ef97a2de7e9bed0148d842..630733786a3194b07448f3df17eb4f2bd27f4808 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-08  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR c/87286
+       * c-common.c (vector_types_compatible_elements_p): Use
+       INTEGRAL_TYPE_P instead of checking only for INTEGER_TYPE.
+
 2018-10-04  Vinay Kumar  <vinay.kumar@blackfigtech.com>
 
        * c-attribs.c (get_priority): Add a warning flag warn_prio_ctor_dtor
index 10a8bc29bfac05917a46061d695fa648756c15fc..c0198e171ad6affbbf9792624ca51d38869eaee3 100644 (file)
@@ -7465,8 +7465,11 @@ vector_types_compatible_elements_p (tree t1, tree t2)
 
   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 t1, tree t2)
   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 a0b6eade3e8ffe3b20e6f1da13ac682528abf96e..7b8bdc737668b0ce0e9c51de50dde74b8690e691 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-08  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR c/87286
+       * gcc.dg/pr87286.c: New test.
+
 2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/86111
diff --git a/gcc/testsuite/gcc.dg/pr87286.c b/gcc/testsuite/gcc.dg/pr87286.c
new file mode 100644 (file)
index 0000000..d92d29c
--- /dev/null
@@ -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; }