blob: 99724623207f124792e15fe7f749d7d8264bc3ed [file] [log] [blame]
Inna Palantff3f07a2019-07-11 16:15:26 -07001// 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
38void ppo(){} // First test that we do not diagnose on this.
39
40#pragma clang diagnostic warning "-Weverything"
41void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
Chih-Hung Hsieh43f06942019-12-19 15:01:08 -080042// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
Inna Palantff3f07a2019-07-11 16:15:26 -070043
44#pragma clang diagnostic ignored "-Weverything" // Reset it.
45void ppq(){}
46
47#pragma clang diagnostic error "-Weverything" // Now set to error
48void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
Chih-Hung Hsieh43f06942019-12-19 15:01:08 -080049// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
Inna Palantff3f07a2019-07-11 16:15:26 -070050
51#pragma clang diagnostic warning "-Weverything" // This should not be effective
52void pps(){} // expected-error {{no previous prototype for function 'pps'}}
Chih-Hung Hsieh43f06942019-12-19 15:01:08 -080053// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}