From: Richard Sandiford Date: Mon, 8 Oct 2018 08:16:13 +0000 (+0000) Subject: Don't ICE on vectors of enums (PR 87286) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8656dafa39de8e537940433220e8f5db3bf7a614;p=gcc.git 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 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 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b6ff1f783b3..630733786a3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2018-10-08 Richard Sandiford + + 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 * c-attribs.c (get_priority): Add a warning flag warn_prio_ctor_dtor diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 10a8bc29bfa..c0198e171ad 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0b6eade3e8..7b8bdc73766 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-08 Richard Sandiford + + PR c/87286 + * gcc.dg/pr87286.c: New test. + 2018-10-06 Thomas Koenig PR fortran/86111 diff --git a/gcc/testsuite/gcc.dg/pr87286.c b/gcc/testsuite/gcc.dg/pr87286.c new file mode 100644 index 00000000000..d92d29ccee7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr87286.c @@ -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; }