summaryrefslogtreecommitdiff
path: root/test/Analysis/temporaries.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /test/Analysis/temporaries.cpp
parentf73d5f23a889b93d89ddef61ac0995df40286bb8 (diff)
downloadsrc-test2-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.tar.gz
src-test2-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.zip
Notes
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
}