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 // rdar://2362963
4
5 #if FOO // ok.
6 #endif
7
8 #pragma GCC diagnostic warning "-Wundef"
9
10 #if FOO // expected-warning {{'FOO' is not defined}}
11 #endif
12
13 #pragma GCC diagnostic ignored "-Wun" "def"
14
15 #if FOO // ok.
16 #endif
17
18 #pragma GCC diagnostic error "-Wundef"
19
20 #if FOO // expected-error {{'FOO' is not defined}}
21 #endif
22
23
24 #define foo error
25 #pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
26
27 #pragma GCC diagnostic error 42 // expected-error {{expected string literal in pragma diagnostic}}
28
29 #pragma GCC diagnostic error "-Wundef" 42 // expected-warning {{unexpected token in pragma diagnostic}}
30 #pragma GCC diagnostic error "invalid-name" // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}}
31
32 #pragma GCC diagnostic error "-Winvalid-name"
33 #ifndef AVOID_UNKNOWN_WARNING
34 // expected-warning@-2 {{unknown warning group '-Winvalid-name', ignored}}
35 #endif
36
37 // Testing pragma clang diagnostic with -Weverything
ppo()38 void ppo(){} // First test that we do not diagnose on this.
39
40 #pragma clang diagnostic warning "-Weverything"
ppp()41 void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
42 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
43
44 #pragma clang diagnostic ignored "-Weverything" // Reset it.
ppq()45 void ppq(){}
46
47 #pragma clang diagnostic error "-Weverything" // Now set to error
ppr()48 void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
49 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
50
51 #pragma clang diagnostic warning "-Weverything" // This should not be effective
pps()52 void pps(){} // expected-error {{no previous prototype for function 'pps'}}
53 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
54