Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 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 |
| 38 | void ppo(){} // First test that we do not diagnose on this. |
| 39 | |
| 40 | #pragma clang diagnostic warning "-Weverything" |
| 41 | void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}} |
Chih-Hung Hsieh | 43f0694 | 2019-12-19 15:01:08 -0800 | [diff] [blame^] | 42 | // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}} |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 43 | |
| 44 | #pragma clang diagnostic ignored "-Weverything" // Reset it. |
| 45 | void ppq(){} |
| 46 | |
| 47 | #pragma clang diagnostic error "-Weverything" // Now set to error |
| 48 | void ppr(){} // expected-error {{no previous prototype for function 'ppr'}} |
Chih-Hung Hsieh | 43f0694 | 2019-12-19 15:01:08 -0800 | [diff] [blame^] | 49 | // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}} |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 50 | |
| 51 | #pragma clang diagnostic warning "-Weverything" // This should not be effective |
| 52 | void pps(){} // expected-error {{no previous prototype for function 'pps'}} |
Chih-Hung Hsieh | 43f0694 | 2019-12-19 15:01:08 -0800 | [diff] [blame^] | 53 | // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}} |