From 9bb45a958d5281b3979f538a05ffa80c6833c4f7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 15 Mar 2018 08:37:53 +0100 Subject: [PATCH] re PR c/84853 (ICE: verify_gimple failed (expand_shift_1)) PR c/84853 * c-typeck.c (build_binary_op) : 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 | 7 +++++++ gcc/c/c-typeck.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 ++++- gcc/testsuite/gcc.dg/pr84853.c | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr84853.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 8147835935c..37a4177ff19 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2018-03-15 Jakub Jelinek + + PR c/84853 + * c-typeck.c (build_binary_op) : + If code1 is INTEGER_TYPE, only allow code0 VECTOR_TYPE if it has + INTEGER_TYPE element type. + 2018-03-13 David Pagan PR c/46921 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 2ac85003ebb..69ef470af2e 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d815ea5b9d8..b2da077edb1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,7 @@ -gcc/testsuite/ChangeLog: +2018-03-15 Jakub Jelinek + + PR c/84853 + * gcc.dg/pr84853.c: New test. 2018-03-14 Carl Love diff --git a/gcc/testsuite/gcc.dg/pr84853.c b/gcc/testsuite/gcc.dg/pr84853.c new file mode 100644 index 00000000000..c74526369a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84853.c @@ -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 >>" } */ +} -- 2.30.2