summaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/uninit-variables-conditional.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/uninit-variables-conditional.cpp')
-rw-r--r--clang/test/SemaCXX/uninit-variables-conditional.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/uninit-variables-conditional.cpp b/clang/test/SemaCXX/uninit-variables-conditional.cpp
new file mode 100644
index 0000000..3c44c72
--- /dev/null
+++ b/clang/test/SemaCXX/uninit-variables-conditional.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -Wconditional-uninitialized -fsyntax-only %s -verify
+
+class Foo {
+public:
+ Foo();
+ ~Foo();
+ operator bool();
+};
+
+int bar();
+int baz();
+int init(double *);
+
+// This case flags a false positive under -Wconditional-uninitialized because
+// the destructor in Foo fouls about the minor bit of path-sensitivity in
+// -Wuninitialized.
+double test() {
+ double x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ if (bar() || baz() || Foo() || init(&x))
+ return 1.0;
+
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}