| 1 |
// RUN: %clang_cc1 %s -Eonly -verify |
| 2 |
|
| 3 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 4 |
#ifdef FOO |
| 5 |
#elifdef BAR |
| 6 |
#error "did not expect to get here" |
| 7 |
#endif |
| 8 |
|
| 9 |
/* expected-error@+5 {{"got it"}} */ |
| 10 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 11 |
#ifdef FOO |
| 12 |
#elifdef BAR |
| 13 |
#else |
| 14 |
#error "got it" |
| 15 |
#endif |
| 16 |
|
| 17 |
/* expected-error@+4 {{"got it"}} */ |
| 18 |
/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 19 |
#ifdef FOO |
| 20 |
#elifndef BAR |
| 21 |
#error "got it" |
| 22 |
#endif |
| 23 |
|
| 24 |
/* expected-error@+4 {{"got it"}} */ |
| 25 |
/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 26 |
#ifdef FOO |
| 27 |
#elifndef BAR |
| 28 |
#error "got it" |
| 29 |
#else |
| 30 |
#error "did not expect to get here" |
| 31 |
#endif |
| 32 |
|
| 33 |
#define BAR |
| 34 |
/* expected-error@+4 {{"got it"}} */ |
| 35 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 36 |
#ifdef FOO |
| 37 |
#elifdef BAR |
| 38 |
#error "got it" |
| 39 |
#endif |
| 40 |
#undef BAR |
| 41 |
|
| 42 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 43 |
#ifdef FOO |
| 44 |
#elifdef BAR // test that comments aren't an issue |
| 45 |
#error "did not expect to get here" |
| 46 |
#endif |
| 47 |
|
| 48 |
/* expected-error@+5 {{"got it"}} */ |
| 49 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 50 |
#ifdef FOO |
| 51 |
#elifdef BAR // test that comments aren't an issue |
| 52 |
#else |
| 53 |
#error "got it" |
| 54 |
#endif |
| 55 |
|
| 56 |
/* expected-error@+4 {{"got it"}} */ |
| 57 |
/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 58 |
#ifdef FOO |
| 59 |
#elifndef BAR // test that comments aren't an issue |
| 60 |
#error "got it" |
| 61 |
#endif |
| 62 |
|
| 63 |
/* expected-error@+4 {{"got it"}} */ |
| 64 |
/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 65 |
#ifdef FOO |
| 66 |
#elifndef BAR // test that comments aren't an issue |
| 67 |
#error "got it" |
| 68 |
#else |
| 69 |
#error "did not expect to get here" |
| 70 |
#endif |
| 71 |
|
| 72 |
#define BAR |
| 73 |
/* expected-error@+4 {{"got it"}} */ |
| 74 |
/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 75 |
#ifdef FOO |
| 76 |
#elifdef BAR // test that comments aren't an issue |
| 77 |
#error "got it" |
| 78 |
#endif |
| 79 |
#undef BAR |
| 80 |
|
| 81 |
#define BAR |
| 82 |
/* expected-error@+7 {{"got it"}} */ |
| 83 |
/* expected-warning@+3 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 84 |
#ifdef FOO |
| 85 |
#error "did not expect to get here" |
| 86 |
#elifndef BAR |
| 87 |
#error "did not expect to get here" |
| 88 |
#else |
| 89 |
#error "got it" |
| 90 |
#endif |
| 91 |
#undef BAR |
| 92 |
|
| 93 |
/* expected-error@+4 {{#elifdef after #else}} */ |
| 94 |
/* expected-warning@+3 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 95 |
#ifdef FOO |
| 96 |
#else |
| 97 |
#elifdef BAR |
| 98 |
#endif |
| 99 |
|
| 100 |
/* expected-error@+4 {{#elifndef after #else}} */ |
| 101 |
/* expected-warning@+3 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 102 |
#ifdef FOO |
| 103 |
#else |
| 104 |
#elifndef BAR |
| 105 |
#endif |
| 106 |
|
| 107 |
/* expected-warning@+1 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 108 |
#elifdef FOO /* expected-error {{#elifdef without #if}} */ |
| 109 |
#endif /* expected-error {{#endif without #if}} */ |
| 110 |
|
| 111 |
/* expected-warning@+1 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 112 |
#elifndef FOO /* expected-error {{#elifndef without #if}} */ |
| 113 |
#endif /* expected-error {{#endif without #if}} */ |
| 114 |
|
| 115 |
/* Note, we do not expect errors about the missing macro name in the skipped |
| 116 |
blocks. This is consistent with #elif behavior. */ |
| 117 |
/* expected-error@+4 {{"got it"}} */ |
| 118 |
/* expected-warning@+4 {{use of a '#elifdef' directive is a C23 extension}} */ |
| 119 |
/* expected-warning@+4 {{use of a '#elifndef' directive is a C23 extension}} */ |
| 120 |
#ifndef FOO |
| 121 |
#error "got it" |
| 122 |
#elifdef |
| 123 |
#elifndef |
| 124 |
#endif |
| 125 |
|
| 126 |
/* expected-error@+3 {{#elif after #else}}*/ |
| 127 |
#if 1 |
| 128 |
#else |
| 129 |
#elif |
| 130 |
#endif |