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

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
This commit is contained in:
Richard Sandiford 2018-10-08 08:16:13 +00:00 committed by Richard Sandiford
parent 090680870b
commit 8656dafa39
4 changed files with 20 additions and 3 deletions

View 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

View 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;

View 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

View File

@ -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; }