aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/uninit-variables-conditional.cpp
blob: 3324215621bf8b8db9c58a90e87b7792d6ef8f66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 1.0;

  return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
}