diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-17 05:29:57 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-17 05:29:57 +0000 |
commit | c5e43c19ddb40b8a1371291f73ae66fe54951ca5 (patch) | |
tree | dcdaebb4ea13a6bdb3d492345171e29add50c3b0 /test/SemaCXX/uninit-variables-conditional.cpp | |
parent | c9dcb45795d9be5c33d4cc03ebfab5ee2f173a7c (diff) |
Don't construct two CFGs just to run -Wuninitialized. While this causes new warnings to be flagged under -Wconditional-uninitialized, this is something we
can improve over time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/uninit-variables-conditional.cpp')
-rw-r--r-- | test/SemaCXX/uninit-variables-conditional.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/SemaCXX/uninit-variables-conditional.cpp b/test/SemaCXX/uninit-variables-conditional.cpp new file mode 100644 index 0000000000..1a822853d9 --- /dev/null +++ b/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 {{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + if (bar() || baz() || Foo() || init(&x)) { + return x; // expected-warning {{variable 'x' is possibly uninitialized when used here}} + } + return 1.0; +} |