diff options
author | Jan Beulich <jbeulich@suse.com> | 2016-08-01 09:39:52 +0000 |
---|---|---|
committer | Jan Beulich <jbeulich@gcc.gnu.org> | 2016-08-01 09:39:52 +0000 |
commit | 76e2c821a4c49fa870a5af4c24501bb821afda93 (patch) | |
tree | c33699b002f7c68697dd27cd0f86b3ad7e46ea09 /gcc/c/c-fold.c | |
parent | 77c3c27eccd630e2484a7b65a0d2f20d883e1908 (diff) | |
download | gcc-76e2c821a4c49fa870a5af4c24501bb821afda93.zip gcc-76e2c821a4c49fa870a5af4c24501bb821afda93.tar.gz gcc-76e2c821a4c49fa870a5af4c24501bb821afda93.tar.bz2 |
extend shift count warnings to vector types
gcc/c/
2016-08-01 Jan Beulich <jbeulich@suse.com>
* c-fold.c (c_fully_fold_internal): Also emit shift count
warnings for vector types.
* c-typeck.c (build_binary_op): Likewise.
gcc/testsuite/
2016-08-01 Jan Beulich <jbeulich@suse.com>
* gcc.dg/vshift-6.c, gcc.dg/vshift-7.c: New.
From-SVN: r238936
Diffstat (limited to 'gcc/c/c-fold.c')
-rw-r--r-- | gcc/c/c-fold.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 6c82f24..8bc3a9c1 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -320,8 +320,6 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, if ((code == LSHIFT_EXPR || code == RSHIFT_EXPR) && TREE_CODE (orig_op1) != INTEGER_CST && TREE_CODE (op1) == INTEGER_CST - && (TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE - || TREE_CODE (TREE_TYPE (orig_op0)) == FIXED_POINT_TYPE) && TREE_CODE (TREE_TYPE (orig_op1)) == INTEGER_TYPE && c_inhibit_evaluation_warnings == 0) { @@ -330,13 +328,23 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, (code == LSHIFT_EXPR ? G_("left shift count is negative") : G_("right shift count is negative"))); - else if (compare_tree_int (op1, - TYPE_PRECISION (TREE_TYPE (orig_op0))) - >= 0) + else if ((TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE + || TREE_CODE (TREE_TYPE (orig_op0)) == FIXED_POINT_TYPE) + && compare_tree_int (op1, + TYPE_PRECISION (TREE_TYPE (orig_op0))) + >= 0) warning_at (loc, OPT_Wshift_count_overflow, (code == LSHIFT_EXPR ? G_("left shift count >= width of type") : G_("right shift count >= width of type"))); + else if (TREE_CODE (TREE_TYPE (orig_op0)) == VECTOR_TYPE + && compare_tree_int (op1, + TYPE_PRECISION (TREE_TYPE (TREE_TYPE (orig_op0)))) + >= 0) + warning_at (loc, OPT_Wshift_count_overflow, + code == LSHIFT_EXPR + ? G_("left shift count >= width of vector element") + : G_("right shift count >= width of vector element")); } if (code == LSHIFT_EXPR /* If either OP0 has been folded to INTEGER_CST... */ |