| 1 |
// RUN: %clang_cc1 -verify -Wswitch -Wreturn-type -triple x86_64-apple-macosx10.12 %s |
| 2 |
// RUN: %clang_cc1 -verify -Wswitch -Wreturn-type -Wno-deprecated-declarations-switch-case -DNO_DEPRECATED_CASE -triple x86_64-apple-macosx10.12 %s |
| 3 |
|
| 4 |
enum SwitchOne { |
| 5 |
Unavail __attribute__((availability(macos, unavailable))), |
| 6 |
}; |
| 7 |
|
| 8 |
void testSwitchOne(enum SwitchOne so) { |
| 9 |
switch (so) {} // no warning |
| 10 |
} |
| 11 |
|
| 12 |
enum SwitchTwo { |
| 13 |
Ed __attribute__((availability(macos, deprecated=10.12))), |
| 14 |
Vim __attribute__((availability(macos, deprecated=10.13))), |
| 15 |
Emacs, |
| 16 |
}; |
| 17 |
|
| 18 |
void testSwitchTwo(enum SwitchTwo st) { |
| 19 |
switch (st) {} // expected-warning{{enumeration values 'Ed', 'Vim', and 'Emacs' not handled in switch}} |
| 20 |
} |
| 21 |
|
| 22 |
enum SwitchThree { |
| 23 |
New __attribute__((availability(macos, introduced=1000))), |
| 24 |
}; |
| 25 |
|
| 26 |
void testSwitchThree(enum SwitchThree st) { |
| 27 |
switch (st) {} // expected-warning{{enumeration value 'New' not handled in switch}} |
| 28 |
} |
| 29 |
|
| 30 |
enum SwitchFour { |
| 31 |
Red, |
| 32 |
Green, |
| 33 |
#ifndef NO_DEPRECATED_CASE |
| 34 |
// expected-note@+2{{'Blue' has been explicitly marked deprecated here}} |
| 35 |
#endif |
| 36 |
Blue [[deprecated]] |
| 37 |
}; |
| 38 |
|
| 39 |
int testSwitchFour(enum SwitchFour e) { |
| 40 |
switch (e) { // expected-warning{{enumeration value 'Blue' not handled in switch}} |
| 41 |
case Red: return 1; |
| 42 |
case Green: return 2; |
| 43 |
} |
| 44 |
} // expected-warning{{non-void function does not return a value in all control paths}} |
| 45 |
|
| 46 |
int testSwitchFourCovered(enum SwitchFour e) { |
| 47 |
switch (e) { |
| 48 |
case Red: return 1; |
| 49 |
case Green: return 2; |
| 50 |
#ifndef NO_DEPRECATED_CASE |
| 51 |
// expected-warning@+2{{'Blue' is deprecated}} |
| 52 |
#endif |
| 53 |
case Blue: return 3; |
| 54 |
} // no warning |
| 55 |
} |