2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-10-18 03:32:54 +08:00
|
|
|
|
|
|
|
void test() {
|
|
|
|
bool x = true;
|
|
|
|
switch (x) { // expected-warning {{bool}}
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int n = 3;
|
|
|
|
switch (n && 1) { // expected-warning {{bool}}
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-11-23 21:46:08 +08:00
|
|
|
|
|
|
|
// PR5518
|
|
|
|
struct A {
|
|
|
|
operator int(); // expected-note{{conversion to integral type}}
|
|
|
|
};
|
|
|
|
|
|
|
|
void x() {
|
|
|
|
switch(A()) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum E { e1, e2 };
|
|
|
|
struct B : A {
|
|
|
|
operator E() const; // expected-note{{conversion to enumeration type}}
|
|
|
|
};
|
|
|
|
|
|
|
|
void x2() {
|
|
|
|
switch (B()) { // expected-error{{multiple conversions}}
|
|
|
|
}
|
|
|
|
}
|
2009-11-23 21:53:21 +08:00
|
|
|
|
|
|
|
struct C; // expected-note{{forward declaration}}
|
|
|
|
|
|
|
|
void x3(C &c) {
|
|
|
|
switch (c) { // expected-error{{incomplete class type}}
|
|
|
|
}
|
|
|
|
}
|