]> granicus.if.org Git - clang/commitdiff
testing: Merge PR3135.c into misc-ps-region-store.m.
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 20:32:38 +0000 (20:32 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 20:32:38 +0000 (20:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86286 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/PR3135.c [deleted file]
test/Analysis/misc-ps-region-store.m

diff --git a/test/Analysis/PR3135.c b/test/Analysis/PR3135.c
deleted file mode 100644 (file)
index 1fca57b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
-// PR3135
-
-typedef struct {
-  int *a;
-} structure;
-
-int bar(structure *x);
-
-int foo()
-{
-  int x;
-  structure y = {&x};
-
-  // the call to bar may initialize x
-  if (bar(&y) && x) // no-warning
-    return 1;
-
-  return 0;
-}
index 90242abbbd52904129b7db89acc8e7789450cf3b..45eb4a252c25d2340a9ce14c1b609f4b9c65576b 100644 (file)
@@ -454,3 +454,19 @@ int *test_cwe466_return_outofbounds_pointer() {
   return p; // expected-warning{{Returned pointer value points outside the original object}}
 }
 
+//===----------------------------------------------------------------------===//
+// PR 3135 - Test case that shows that a variable may get invalidated when its
+// address is included in a structure that is passed-by-value to an unknown function.
+//===----------------------------------------------------------------------===//
+
+typedef struct { int *a; } pr3135_structure;
+int pr3135_bar(pr3135_structure *x);
+int pr3135() {
+  int x;
+  pr3135_structure y = { &x };
+  // the call to pr3135_bar may initialize x
+  if (pr3135_bar(&y) && x) // no-warning
+    return 1;
+  return 0;
+}
+