diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-08-19 09:27:16 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-08-19 15:26:10 -0400 |
commit | fc02b568e2cd3f6a28d4b7c1063bbf8842c89aad (patch) | |
tree | 86fb127e6887d951ef3d323ea1074f125c73ddf5 | |
parent | 366bd1ac01a5249a463e64234674ad2d174faa9a (diff) | |
download | gcc-fc02b568e2cd3f6a28d4b7c1063bbf8842c89aad.zip gcc-fc02b568e2cd3f6a28d4b7c1063bbf8842c89aad.tar.gz gcc-fc02b568e2cd3f6a28d4b7c1063bbf8842c89aad.tar.bz2 |
analyzer: fix ICE on folding vector 0 [PR96705]
gcc/analyzer/ChangeLog:
* region-model-manager.cc
PR analyzer/96705
(region_model_manager::maybe_fold_binop): Check that we have an
integral type before calling build_int_cst.
gcc/testsuite/ChangeLog:
PR analyzer/96705
* gcc.dg/analyzer/pr96705.c: New test.
-rw-r--r-- | gcc/analyzer/region-model-manager.cc | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/pr96705.c | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 0792574..422c4a9 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -445,7 +445,7 @@ region_model_manager::maybe_fold_binop (tree type, enum tree_code op, break; case MULT_EXPR: /* (VAL * 0). */ - if (cst1 && zerop (cst1)) + if (cst1 && zerop (cst1) && INTEGRAL_TYPE_P (type)) return get_or_create_constant_svalue (build_int_cst (type, 0)); /* (VAL * 1) -> VAL. */ if (cst1 && integer_onep (cst1)) @@ -455,7 +455,7 @@ region_model_manager::maybe_fold_binop (tree type, enum tree_code op, case TRUTH_AND_EXPR: if (cst1) { - if (zerop (cst1)) + if (zerop (cst1) && INTEGRAL_TYPE_P (type)) /* "(ARG0 && 0)" -> "0". */ return get_or_create_constant_svalue (build_int_cst (type, 0)); else diff --git a/gcc/testsuite/gcc.dg/analyzer/pr96705.c b/gcc/testsuite/gcc.dg/analyzer/pr96705.c new file mode 100644 index 0000000..d7856d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr96705.c @@ -0,0 +1,9 @@ +int __attribute__ ((vector_size (8))) v; +int i; + +void +test (void) +{ + v &= 0; + v *= i; +} |