]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: avoid usage of TYPE_PRECISION on vector types [PR110455]
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 21 Jul 2023 00:24:10 +0000 (20:24 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 21 Jul 2023 00:24:10 +0000 (20:24 -0400)
gcc/analyzer/ChangeLog:
PR analyzer/110455
* region-model.cc (region_model::get_gassign_result): Only check
for bad shift counts when dealing with an integral type.

gcc/testsuite/ChangeLog:
PR analyzer/110455
* gcc.dg/analyzer/pr110455.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model.cc
gcc/testsuite/gcc.dg/analyzer/pr110455.c [new file with mode: 0644]

index 187013a37cc5fff0a42fa8e5bc3a24bfc3ab6778..e01b1c88299349aaacd7249fd573e57a48d3e6ee 100644 (file)
@@ -860,7 +860,8 @@ region_model::get_gassign_result (const gassign *assign,
               or by greater than or equal to the number of bits that exist in
               the operand."  */
            if (const tree rhs2_cst = rhs2_sval->maybe_get_constant ())
-             if (TREE_CODE (rhs2_cst) == INTEGER_CST)
+             if (TREE_CODE (rhs2_cst) == INTEGER_CST
+                 && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
                {
                  if (tree_int_cst_sgn (rhs2_cst) < 0)
                    ctxt->warn
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr110455.c b/gcc/testsuite/gcc.dg/analyzer/pr110455.c
new file mode 100644 (file)
index 0000000..7f97943
--- /dev/null
@@ -0,0 +1,7 @@
+int __attribute__((__vector_size__ (4))) v;
+
+void
+foo (void)
+{
+  v | v << 1;
+}