Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Preprocessor / pragma_diagnostic.c
blobff379079b7bafaafdde0a34b58731148d262c497
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
5 #ifdef INITIAL_UNDEF
6 #if FOO // expected-error {{'FOO' is not defined}}
7 #endif
8 #else
9 #if FOO // ok.
10 #endif
11 #endif
13 #pragma GCC diagnostic warning "-Wundef"
15 #if FOO // expected-warning {{'FOO' is not defined}}
16 #endif
18 #pragma GCC diagnostic ignored "-Wun" "def"
20 #if FOO // ok.
21 #endif
23 #pragma GCC diagnostic error "-Wundef"
25 #if FOO // expected-error {{'FOO' is not defined}}
26 #endif
29 #define foo error
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}}
40 #endif
42 // From GH13920
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.
55 void ppq(void){}
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}}