re PR c/84853 (ICE: verify_gimple failed (expand_shift_1))
authorJakub Jelinek <jakub@redhat.com>
Thu, 15 Mar 2018 07:37:53 +0000 (08:37 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 15 Mar 2018 07:37:53 +0000 (08:37 +0100)
PR c/84853
* c-typeck.c (build_binary_op) <case RSHIFT_EXPR, case LSHIFT_EXPR>:
If code1 is INTEGER_TYPE, only allow code0 VECTOR_TYPE if it has
INTEGER_TYPE element type.

* gcc.dg/pr84853.c: New test.

From-SVN: r258550

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84853.c [new file with mode: 0644]

index 8147835935ceef5843f555570ff56cca39f195b2..37a4177ff194c634c298a471ac447c049e9b40d9 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/84853
+       * c-typeck.c (build_binary_op) <case RSHIFT_EXPR, case LSHIFT_EXPR>:
+       If code1 is INTEGER_TYPE, only allow code0 VECTOR_TYPE if it has
+       INTEGER_TYPE element type.
+
 2018-03-13  David Pagan  <dave.pagan@oracle.com>
 
        PR c/46921
index 2ac85003ebb2059eff9ff0d207758227ad4e751f..69ef470af2e232cd9e8d59fa8a4d1dd1634c089d 100644 (file)
@@ -11350,7 +11350,8 @@ build_binary_op (location_t location, enum tree_code code,
          converted = 1;
        }
       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
-               || code0 == VECTOR_TYPE)
+               || (code0 == VECTOR_TYPE
+                   && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
               && code1 == INTEGER_TYPE)
        {
          doing_shift = true;
@@ -11408,7 +11409,8 @@ build_binary_op (location_t location, enum tree_code code,
          converted = 1;
        }
       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
-               || code0 == VECTOR_TYPE)
+               || (code0 == VECTOR_TYPE
+                   && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
               && code1 == INTEGER_TYPE)
        {
          doing_shift = true;
index d815ea5b9d8a2ee6a25ee3c0e16e3bceb8646fdf..b2da077edb1e92ec54627226581c299626fecc71 100644 (file)
@@ -1,4 +1,7 @@
-gcc/testsuite/ChangeLog:
+2018-03-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/84853
+       * gcc.dg/pr84853.c: New test.
 
 2018-03-14  Carl Love  <cel@us.ibm.com>
 
diff --git a/gcc/testsuite/gcc.dg/pr84853.c b/gcc/testsuite/gcc.dg/pr84853.c
new file mode 100644 (file)
index 0000000..c745263
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR c/84853 */
+/* { dg-do compile } */
+
+typedef float V __attribute__((__vector_size__ (16)));
+typedef int W __attribute__((__vector_size__ (16)));
+
+void
+foo (int x, V *y, V *z, W *w)
+{
+  *y = *y << x;                /* { dg-error "invalid operands to binary <<" } */
+  *z = *z << *w;       /* { dg-error "invalid operands to binary <<" } */
+}
+
+void
+bar (int x, V *y, V *z, W *w)
+{
+  *y = *y >> x;                /* { dg-error "invalid operands to binary >>" } */
+  *z = *z >> *w;       /* { dg-error "invalid operands to binary >>" } */
+}