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