1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-undef %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-undef -Wno-unknown-warning-option -DAVOID_UNKNOWN_WARNING %s
7 #pragma GCC diagnostic warning "-Wundef"
9 #if FOO // expected-warning {{'FOO' is not defined}}
12 #pragma GCC diagnostic ignored "-Wun" "def"
17 #pragma GCC diagnostic error "-Wundef"
19 #if FOO // expected-error {{'FOO' is not defined}}
24 #pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
26 #pragma GCC diagnostic error 42 // expected-error {{expected string literal in pragma diagnostic}}
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")}}
31 #pragma GCC diagnostic error "-Winvalid-name"
32 #ifndef AVOID_UNKNOWN_WARNING
33 // expected-warning@-2 {{unknown warning group '-Winvalid-name', ignored}}
37 #pragma clang diagnostic push ignored "-Wdeprecated-declarations" // expected-warning {{unexpected token in pragma diagnostic}}
38 #pragma clang diagnostic pop ignored "-Wdeprecated-declarations" // expected-warning {{unexpected token in pragma diagnostic}}
41 // Testing pragma clang diagnostic with -Weverything
42 void ppo(void){} // First test that we do not diagnose on this.
44 #pragma clang diagnostic warning "-Weverything"
45 void ppp(void){} // expected-warning {{no previous prototype for function 'ppp'}}
46 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
48 #pragma clang diagnostic ignored "-Weverything" // Reset it.
51 #pragma clang diagnostic error "-Weverything" // Now set to error
52 void ppr(void){} // expected-error {{no previous prototype for function 'ppr'}}
53 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
55 #pragma clang diagnostic warning "-Weverything" // This should not be effective
56 void pps(void){} // expected-error {{no previous prototype for function 'pps'}}
57 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}