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
3 // RUN: %clang_cc1 -fsyntax-only -verify -Werror=undef -DINITIAL_UNDEF %s
6 #if FOO // expected-error {{'FOO' is not defined}}
13 #pragma GCC diagnostic warning "-Wundef"
15 #if FOO // expected-warning {{'FOO' is not defined}}
18 #pragma GCC diagnostic ignored "-Wun" "def"
23 #pragma GCC diagnostic error "-Wundef"
25 #if FOO // expected-error {{'FOO' is not defined}}
30 #pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
32 #pragma GCC diagnostic error 42 // expected-error {{expected string literal in pragma diagnostic}}
34 #pragma GCC diagnostic error "-Wundef" 42 // expected-warning {{unexpected token in pragma diagnostic}}
35 #pragma GCC diagnostic error "invalid-name" // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}}
37 #pragma GCC diagnostic error "-Winvalid-name"
38 #ifndef AVOID_UNKNOWN_WARNING
39 // expected-warning@-2 {{unknown warning group '-Winvalid-name', ignored}}
43 #pragma clang diagnostic push ignored "-Wdeprecated-declarations" // expected-warning {{unexpected token in pragma diagnostic}}
44 #pragma clang diagnostic pop ignored "-Wdeprecated-declarations" // expected-warning {{unexpected token in pragma diagnostic}}
47 // Testing pragma clang diagnostic with -Weverything
48 void ppo(void){} // First test that we do not diagnose on this.
50 #pragma clang diagnostic warning "-Weverything"
51 void ppp(void){} // expected-warning {{no previous prototype for function 'ppp'}}
52 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
54 #pragma clang diagnostic ignored "-Weverything" // Reset it.
57 #pragma clang diagnostic error "-Weverything" // Now set to error
58 void ppr(void){} // expected-error {{no previous prototype for function 'ppr'}}
59 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
61 #pragma clang diagnostic warning "-Weverything" // Set to warning
62 void pps(void){} // expected-warning {{no previous prototype for function 'pps'}}
63 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}