analyzer: handle vector types (PR 93350)
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 7 Feb 2020 10:49:24 +0000 (05:49 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 10 Feb 2020 23:00:31 +0000 (18:00 -0500)
gcc/analyzer/ChangeLog:
PR analyzer/93350
* region-model.cc (region_model::get_lvalue_1):
Handle BIT_FIELD_REF.
(make_region_for_type): Handle VECTOR_TYPE.

gcc/testsuite/ChangeLog:
PR analyzer/93350
* gcc.dg/analyzer/torture/pr93350.c: New test.

gcc/analyzer/ChangeLog
gcc/analyzer/region-model.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/torture/pr93350.c [new file with mode: 0644]

index 0960a49eb62cdb2be0946caff9fe3b776f5a67a4..e3f7c43948a948a0b3ab91d4b3288b5fe2cc9c0f 100644 (file)
@@ -1,3 +1,10 @@
+2020-02-10  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93350
+       * region-model.cc (region_model::get_lvalue_1):
+       Handle BIT_FIELD_REF.
+       (make_region_for_type): Handle VECTOR_TYPE.
+
 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93647
index a88a85d70ab5d4edb7ccca9f377055a42d10c224..85155602cb16f76bf5212548b897d190bee0119e 100644 (file)
@@ -4635,6 +4635,14 @@ region_model::get_lvalue_1 (path_var pv, region_model_context *ctxt)
       }
       break;
 
+    case BIT_FIELD_REF:
+      {
+       /* For now, create a view, as if a cast, ignoring the bit positions.  */
+       tree obj = TREE_OPERAND (expr, 0);
+       return get_or_create_view (get_lvalue (obj, ctxt), TREE_TYPE (expr));
+      };
+      break;
+
     case MEM_REF:
       {
        tree ptr = TREE_OPERAND (expr, 0);
@@ -6008,7 +6016,8 @@ make_region_for_type (region_id parent_rid, tree type)
   if (INTEGRAL_TYPE_P (type)
       || SCALAR_FLOAT_TYPE_P (type)
       || POINTER_TYPE_P (type)
-      || TREE_CODE (type) == COMPLEX_TYPE)
+      || TREE_CODE (type) == COMPLEX_TYPE
+      || TREE_CODE (type) == VECTOR_TYPE)
     return new primitive_region (parent_rid, type);
 
   if (TREE_CODE (type) == RECORD_TYPE)
index bb7ecda48e8b680221477f25ebadd13f22cc75ba..290bd8afdfa8c82b0fbce6f097d723beee444371 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-10  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93350
+       * gcc.dg/analyzer/torture/pr93350.c: New test.
+
 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93647
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93350.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93350.c
new file mode 100644 (file)
index 0000000..1799da1
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-Wno-psabi" } */
+
+typedef __INT32_TYPE__   int32_t;
+typedef int32_t vnx4si __attribute__((vector_size (32)));
+
+__attribute__((noipa))
+vnx4si foo(int a, int b)
+{
+  return (vnx4si) { 1, 2, 3, 4, 5, 6, a, b };
+}