]> granicus.if.org Git - clang/commitdiff
[analyzer] Test case: p->x is the same as p[0].x. (PR7297)
authorJordy Rose <jediknil@belkadan.com>
Sat, 12 May 2012 17:32:59 +0000 (17:32 +0000)
committerJordy Rose <jediknil@belkadan.com>
Sat, 12 May 2012 17:32:59 +0000 (17:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156720 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/array-struct-region.c

index 4b085c8d7002ccda9e68b1fceebef710a0cfc1e6..8be86883a00c8aa850ef042b2d6e09b7f7f93668 100644 (file)
@@ -45,3 +45,16 @@ void nested_compound_literals_float(float rad) {
       vec[a][1] *= rad; // no-warning
   }
 }
+
+
+void struct_as_array() {
+  struct simple { int x; };
+  struct simple a;
+  struct simple *p = &a;
+  p->x = 5;
+  if (!p[0].x)
+    return; // expected-warning{{never executed}}
+  if (p[0].x)
+    return; // no-warning
+}
+