| 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 |
| 4 |
|
| 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 |
| 12 |
|
| 13 |
#pragma GCC diagnostic warning "-Wundef" |
| 14 |
|
| 15 |
#if FOO // expected-warning {{'FOO' is not defined}} |
| 16 |
#endif |
| 17 |
|
| 18 |
#pragma GCC diagnostic ignored "-Wun" "def" |
| 19 |
|
| 20 |
#if FOO // ok. |
| 21 |
#endif |
| 22 |
|
| 23 |
#pragma GCC diagnostic error "-Wundef" |
| 24 |
|
| 25 |
#if FOO // expected-error {{'FOO' is not defined}} |
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
#define foo error |
| 30 |
#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} |
| 31 |
|
| 32 |
#pragma GCC diagnostic error 42 // expected-error {{expected string literal in pragma diagnostic}} |
| 33 |
|
| 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")}} |
| 36 |
|
| 37 |
#pragma GCC diagnostic error "-Winvalid-name" |
| 38 |
#ifndef AVOID_UNKNOWN_WARNING |
| 39 |
// expected-warning@-2 {{unknown warning group '-Winvalid-name', ignored}} |
| 40 |
#endif |
| 41 |
|
| 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}} |
| 45 |
|
| 46 |
|
| 47 |
// Testing pragma clang diagnostic with -Weverything |
| 48 |
void ppo(void){} // First test that we do not diagnose on this. |
| 49 |
|
| 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}} |
| 53 |
|
| 54 |
#pragma clang diagnostic ignored "-Weverything" // Reset it. |
| 55 |
void ppq(void){} |
| 56 |
|
| 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}} |
| 60 |
|
| 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}} |