]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/84853 (ICE: verify_gimple failed (expand_shift_1))
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 20:40:45 +0000 (22:40 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 20:40:45 +0000 (22:40 +0200)
Backported from mainline
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.

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

From-SVN: r261922

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

index b48e7cb422ec05cb920b81f57fbf48412729fc08..866ad995ceb14a716eedbef5453d48ef386e9290 100644 (file)
@@ -1,3 +1,13 @@
+2018-06-22  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-01-25  Release Manager
 
        * GCC 7.3.0 released.
index ee365313c817675f7f799daad4d085c0830d3fbd..c72932986fa088d8068bd6992cb698d758563f98 100644 (file)
@@ -11150,7 +11150,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;
@@ -11207,7 +11208,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 98fa2654761f07fd063e7467f08d3bf9abacc88f..4abcfb03f5afdbb3a138fe5ff68a83ca4bb2ea90 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/84853
+       * gcc.dg/pr84853.c: New test.
+
        2018-03-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/84834
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 >>" } */
+}