131 lines · c
1// RUN: %clang_cc1 %s -Eonly -verify2 3/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */4#ifdef FOO5#elifdef BAR6#error "did not expect to get here"7#endif8 9/* expected-error@+5 {{"got it"}} */10/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */11#ifdef FOO12#elifdef BAR13#else14#error "got it"15#endif16 17/* expected-error@+4 {{"got it"}} */18/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */19#ifdef FOO20#elifndef BAR21#error "got it"22#endif23 24/* expected-error@+4 {{"got it"}} */25/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */26#ifdef FOO27#elifndef BAR28#error "got it"29#else30#error "did not expect to get here"31#endif32 33#define BAR34/* expected-error@+4 {{"got it"}} */35/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */36#ifdef FOO37#elifdef BAR38#error "got it"39#endif40#undef BAR41 42/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */43#ifdef FOO44#elifdef BAR // test that comments aren't an issue45#error "did not expect to get here"46#endif47 48/* expected-error@+5 {{"got it"}} */49/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */50#ifdef FOO51#elifdef BAR // test that comments aren't an issue52#else53#error "got it"54#endif55 56/* expected-error@+4 {{"got it"}} */57/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */58#ifdef FOO59#elifndef BAR // test that comments aren't an issue60#error "got it"61#endif62 63/* expected-error@+4 {{"got it"}} */64/* expected-warning@+2 {{use of a '#elifndef' directive is a C23 extension}} */65#ifdef FOO66#elifndef BAR // test that comments aren't an issue67#error "got it"68#else69#error "did not expect to get here"70#endif71 72#define BAR73/* expected-error@+4 {{"got it"}} */74/* expected-warning@+2 {{use of a '#elifdef' directive is a C23 extension}} */75#ifdef FOO76#elifdef BAR // test that comments aren't an issue77#error "got it"78#endif79#undef BAR80 81#define BAR82/* expected-error@+7 {{"got it"}} */83/* expected-warning@+3 {{use of a '#elifndef' directive is a C23 extension}} */84#ifdef FOO85#error "did not expect to get here"86#elifndef BAR87#error "did not expect to get here"88#else89#error "got it"90#endif91#undef BAR92 93/* expected-error@+4 {{#elifdef after #else}} */94/* expected-warning@+3 {{use of a '#elifdef' directive is a C23 extension}} */95#ifdef FOO96#else97#elifdef BAR98#endif99 100/* expected-error@+4 {{#elifndef after #else}} */101/* expected-warning@+3 {{use of a '#elifndef' directive is a C23 extension}} */102#ifdef FOO103#else104#elifndef BAR105#endif106 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 skipped116 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 FOO121#error "got it"122#elifdef123#elifndef124#endif125 126/* expected-error@+3 {{#elif after #else}}*/127#if 1128#else129#elif130#endif131