summaryrefslogtreecommitdiff
path: root/test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
blob: 5390da4f3f5a6af4e4d2da9f992a0d54109f71ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s

void testIf() {
  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
    ;
  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
    ;
  int a;
  if (a = 0; a) {} // OK
}

void testSwitch() {
  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
    case 0:
      break;
  }
  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
    case 0:
      break;
  }
  int c;
  switch (c = 0; c) { // OK
    case 0:
      break;
  }
}