]> granicus.if.org Git - clang/commitdiff
[analyzer] Add regression test for the crash in PR16664.
authorJordan Rose <jordan_rose@apple.com>
Thu, 25 Jul 2013 17:22:05 +0000 (17:22 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 25 Jul 2013 17:22:05 +0000 (17:22 +0000)
This goes with r186925, which reverted Pavel's commit in r186498.

Also, add a correctness test for the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187133 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/temporaries.cpp

index efc0825470cd32e3c2820e8530c682ef9a30084d..ebfbfe9bee3b320db2195b58f40aeedab27a8ea2 100644 (file)
@@ -109,3 +109,35 @@ namespace compound_literals {
   }
 }
 
+namespace destructors {
+  void testPR16664Crash() {
+    struct Dtor {
+      ~Dtor();
+    };
+    extern bool coin();
+    extern bool check(const Dtor &);
+
+    // Don't crash here.
+    if (coin() && (coin() || coin() || check(Dtor()))) {
+      Dtor();
+    }
+  }
+
+  void testConsistency(int i) {
+    struct NoReturnDtor {
+      ~NoReturnDtor() __attribute__((noreturn));
+    };
+    extern bool check(const NoReturnDtor &);
+    
+    if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
+      clang_analyzer_eval(true); // expected-warning{{TRUE}}
+
+    if (i != 5)
+      return;
+    if (i == 5 && (i == 4 || check(NoReturnDtor()) || i == 5)) {
+      // FIXME: Should be no-warning, because the noreturn destructor should
+      // fire on all paths.
+      clang_analyzer_eval(true); // expected-warning{{TRUE}}
+    }
+  }
+}