aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/temporaries.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/temporaries.cpp')
-rw-r--r--test/Analysis/temporaries.cpp65
1 files changed, 49 insertions, 16 deletions
diff --git a/test/Analysis/temporaries.cpp b/test/Analysis/temporaries.cpp
index 6b49fcbddd41..c57d984a1dc8 100644
--- a/test/Analysis/temporaries.cpp
+++ b/test/Analysis/temporaries.cpp
@@ -118,13 +118,11 @@ namespace destructors {
extern bool coin();
extern bool check(const Dtor &);
-#ifndef TEMPORARY_DTORS
- // FIXME: Don't crash here when tmp dtros are enabled.
- // PR16664 and PR18159
+ // Regression test: we used to assert here when tmp dtors are enabled.
+ // PR16664 and PR18159
if (coin() && (coin() || coin() || check(Dtor()))) {
Dtor();
}
-#endif
}
#ifdef TEMPORARY_DTORS
@@ -170,18 +168,16 @@ namespace destructors {
clang_analyzer_eval(true); // no warning, unreachable code
}
-
-/*
- // PR16664 and PR18159
- FIXME: Don't crash here.
+ // Regression test: we used to assert here.
+ // PR16664 and PR18159
void testConsistencyNested(int i) {
extern bool compute(bool);
-
+
if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
- clang_analyzer_eval(true); // expected TRUE
-
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
+
if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
- clang_analyzer_eval(true); // expected TRUE
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
if (i != 5)
return;
@@ -190,17 +186,54 @@ namespace destructors {
(i == 4 || compute(true) ||
compute(i == 5 && (i == 4 || check(NoReturnDtor()))))) ||
i != 4) {
- clang_analyzer_eval(true); // expected TRUE
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
}
if (compute(i == 5 &&
(i == 4 || i == 4 ||
compute(i == 5 && (i == 4 || check(NoReturnDtor()))))) ||
i != 4) {
- clang_analyzer_eval(true); // no warning, unreachable code
+ // FIXME: This shouldn't cause a warning.
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
}
- }*/
-
+ }
+
+ // PR16664 and PR18159
+ void testConsistencyNestedSimple(bool value) {
+ if (value) {
+ if (!value || check(NoReturnDtor())) {
+ clang_analyzer_eval(true); // no warning, unreachable code
+ }
+ }
+ }
+
+ // PR16664 and PR18159
+ void testConsistencyNestedComplex(bool value) {
+ if (value) {
+ if (!value || !value || check(NoReturnDtor())) {
+ // FIXME: This shouldn't cause a warning.
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
+ }
+ }
+ }
+
+ // PR16664 and PR18159
+ void testConsistencyNestedWarning(bool value) {
+ if (value) {
+ if (!value || value || check(NoReturnDtor())) {
+ clang_analyzer_eval(true); // expected-warning{{TRUE}}
+ }
+ }
+ }
+
+ void testBinaryOperatorShortcut(bool value) {
+ if (value) {
+ if (false && false && check(NoReturnDtor()) && true) {
+ clang_analyzer_eval(true);
+ }
+ }
+ }
+
#endif // TEMPORARY_DTORS
}