minix/external/bsd/llvm/dist/clang/test/SemaCXX/uninit-variables-conditional.cpp
Lionel Sambuc f4a2713ac8 Importing netbsd clang -- pristine
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
2014-07-28 17:05:57 +02:00

23 lines
611 B
C++

// 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}}
}