Home | History | Annotate | Download | only in Preprocessor
      1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-undef %s
      2 // rdar://2362963
      3 
      4 #if FOO    // ok.
      5 #endif
      6 
      7 #pragma GCC diagnostic warning "-Wundef"
      8 
      9 #if FOO    // expected-warning {{'FOO' is not defined}}
     10 #endif
     11 
     12 #pragma GCC diagnostic ignored "-Wun" "def"
     13 
     14 #if FOO    // ok.
     15 #endif
     16 
     17 #pragma GCC diagnostic error "-Wundef"
     18 
     19 #if FOO    // expected-error {{'FOO' is not defined}}
     20 #endif
     21 
     22 
     23 #define foo error
     24 #pragma GCC diagnostic foo "-Wundef"  // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
     25 
     26 #pragma GCC diagnostic error 42  // expected-error {{expected string literal in pragma diagnostic}}
     27 
     28 #pragma GCC diagnostic error "-Wundef" 42  // expected-warning {{unexpected token in pragma diagnostic}}
     29 #pragma GCC diagnostic error "invalid-name"  // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}}
     30 
     31 #pragma GCC diagnostic error "-Winvalid-name"  // expected-warning {{unknown warning group '-Winvalid-name', ignored}}
     32 
     33 
     34 // Testing pragma clang diagnostic with -Weverything
     35 void ppo(){} // First test that we do not diagnose on this.
     36 
     37 #pragma clang diagnostic warning "-Weverything"
     38 void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
     39 
     40 #pragma clang diagnostic ignored "-Weverything" // Reset it.
     41 void ppq(){}
     42 
     43 #pragma clang diagnostic error "-Weverything" // Now set to error
     44 void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
     45 
     46 #pragma clang diagnostic warning "-Weverything" // This should not be effective
     47 void pps(){} // expected-error {{no previous prototype for function 'pps'}}
     48