1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 switch (x
) { // expected-warning {{bool}}
11 switch (n
&& true) { // expected-warning {{bool}}
19 operator int(); // expected-note{{conversion to integral type}}
29 operator E() const; // expected-note{{conversion to enumeration type}}
33 switch (B()) { // expected-error{{multiple conversions}}
37 struct C
; // expected-note{{forward declaration}}
40 switch (c
) { // expected-error{{incomplete class type}}
46 template <En how
> void foo() {
49 switch (how
) { //expected-warning {{no case matching constant switch condition '2'}}
50 case A
: x
*= y
; break;
51 case B
: x
+= y
; break;
52 // No case for C, but it's okay because we have a constant condition.
56 template void foo
<A
>();
57 template void foo
<B
>();
58 template void foo
<C
>(); //expected-note {{in instantiation}}
61 // PR9304 and rdar://9045501
62 void click_check_header_sizes() {
63 switch (0 == 8) { // expected-warning {{switch condition has boolean value}}
68 void local_class(int n
) {
73 case 1: // expected-error {{'case' statement not in switch statement}}
74 break; // expected-error {{'break' statement not in loop or switch statement}}
75 default: // expected-error {{'default' statement not in switch statement}}
76 continue; // expected-error {{'continue' statement not in loop statement}}
81 case 2: // expected-error {{'case' statement not in switch statement}}
82 break; // expected-error {{'break' statement not in loop or switch statement}}
83 default: // expected-error {{'default' statement not in switch statement}}
84 continue; // expected-error {{'continue' statement not in loop statement}}
89 namespace Conversion
{
91 explicit operator int(); // expected-note {{conversion}}
93 template<typename T
> void f(T t
) {
94 switch (t
) { // expected-error {{explicit conversion}}
101 template void f(S
); // expected-note {{instantiation of}}
105 namespace OpaqueEnumWarnings
{
108 enum class OpaqueClass
: int;
110 enum class Defined
: int;
111 enum class Defined
: int { a
};
113 void test(Opaque o
, OpaqueClass oc
, Defined d
) {
114 // Don't warn that case value is not present in opaque enums.
127 case (Defined
)2: // expected-warning {{case value not in enumerated type 'OpaqueEnumWarnings::Defined'}}
134 namespace EmptyEnum
{
148 } // namespace EmptyEnum