teak-llvm/clang/test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
Richard Smith a547eb27fa P0305R0: Semantic analysis and code generation for C++17 init-statement for 'if' and 'switch':
if (stmt; condition) { ... }

Patch by Anton Bikineev! Some minor formatting and comment tweets by me.

llvm-svn: 275350
2016-07-14 00:11:03 +00:00

27 lines
664 B
C++

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