blob: 347401fffc2046ca0d81951cfbee7228c987af4c [file] [log] [blame]
Richard Smithd230de22017-01-26 01:01:01 +00001// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -fmodules-ts
3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts
4// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -fmodules-ts -o %t/explicit.pcm -Werror=string-plus-int
5// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm
6
7import diag_pragma;
8
9int foo(int x) {
10 // Diagnostics from templates in the module follow the diagnostic state from
11 // when the module was built.
12#ifdef EXPLICIT_FLAG
13 // expected-error@diag_pragma.h:7 {{adding 'int' to a string}}
14#else
15 // expected-warning@diag_pragma.h:7 {{adding 'int' to a string}}
16#endif
17 // expected-note@diag_pragma.h:7 {{use array indexing}}
18 f(0); // expected-note {{instantiation of}}
19
20 g(0); // ok, warning was ignored when building module
21
22 // Diagnostics from this source file ignore the diagnostic state from the
23 // module.
24 void("foo" + x); // expected-warning {{adding 'int' to a string}}
25 // expected-note@-1 {{use array indexing}}
26
27#pragma clang diagnostic ignored "-Wstring-plus-int"
28
29 // Diagnostics from the module ignore diagnostic state changes from this
30 // source file.
31#ifdef EXPLICIT_FLAG
32 // expected-error@diag_pragma.h:7 {{adding 'long' to a string}}
33#else
34 // expected-warning@diag_pragma.h:7 {{adding 'long' to a string}}
35#endif
36 // expected-note@diag_pragma.h:7 {{use array indexing}}
37 f(0L); // expected-note {{instantiation of}}
38
39 g(0L);
40
41 void("bar" + x);
42
43 if (x = DIAG_PRAGMA_MACRO) // expected-warning {{using the result of an assignment as a condition without parentheses}} \
44 // expected-note {{place parentheses}} expected-note {{use '=='}}
45 return 0;
46 return 1;
47}