150
|
1 // RUN: rm -rf %t
|
252
|
2 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -std=c++20
|
|
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20
|
|
4 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -std=c++20 -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 -std=c++20 -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm
|
150
|
6
|
|
7 import diag_pragma;
|
|
8
|
|
9 int 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 '=='}}
|
252
|
45 // expected-error@-2 {{use of undeclared identifier 'DIAG_PRAGMA_MACRO'}}
|
150
|
46 return 0;
|
|
47 return 1;
|
|
48 }
|