brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 6077790 Raw
56 lines · c
1// RUN: %clang_cc1 -verify -Wswitch -Wreturn-type -triple x86_64-apple-macosx10.12 %s2// RUN: %clang_cc1 -verify -Wswitch -Wreturn-type -Wno-deprecated-declarations-switch-case -DNO_DEPRECATED_CASE -triple x86_64-apple-macosx10.12 %s3 4enum SwitchOne {5  Unavail __attribute__((availability(macos, unavailable))),6};7 8void testSwitchOne(enum SwitchOne so) {9  switch (so) {} // no warning10}11 12enum SwitchTwo {13  Ed __attribute__((availability(macos, deprecated=10.12))),14  Vim __attribute__((availability(macos, deprecated=10.13))),15  Emacs,16};17 18void testSwitchTwo(enum SwitchTwo st) {19  switch (st) {} // expected-warning{{enumeration values 'Ed', 'Vim', and 'Emacs' not handled in switch}}20}21 22enum SwitchThree {23  New __attribute__((availability(macos, introduced=1000))),24};25 26void testSwitchThree(enum SwitchThree st) {27  switch (st) {} // expected-warning{{enumeration value 'New' not handled in switch}}28}29 30enum SwitchFour {31  Red,32  Green,33#ifndef NO_DEPRECATED_CASE34// expected-note@+2{{'Blue' has been explicitly marked deprecated here}}35#endif36  Blue [[deprecated]]37};38 39int 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 46int testSwitchFourCovered(enum SwitchFour e) {47  switch (e) {48  case Red:   return 1;49  case Green: return 2;50#ifndef NO_DEPRECATED_CASE51// expected-warning@+2{{'Blue' is deprecated}}52#endif53  case Blue:  return 3;54  } // no warning55}56