annotate clang/test/Modules/diag-pragma.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: rm -rf %t
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 import diag_pragma;
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 int foo(int x) {
anatofuz
parents:
diff changeset
10 // Diagnostics from templates in the module follow the diagnostic state from
anatofuz
parents:
diff changeset
11 // when the module was built.
anatofuz
parents:
diff changeset
12 #ifdef EXPLICIT_FLAG
anatofuz
parents:
diff changeset
13 // expected-error@diag_pragma.h:7 {{adding 'int' to a string}}
anatofuz
parents:
diff changeset
14 #else
anatofuz
parents:
diff changeset
15 // expected-warning@diag_pragma.h:7 {{adding 'int' to a string}}
anatofuz
parents:
diff changeset
16 #endif
anatofuz
parents:
diff changeset
17 // expected-note@diag_pragma.h:7 {{use array indexing}}
anatofuz
parents:
diff changeset
18 f(0); // expected-note {{instantiation of}}
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 g(0); // ok, warning was ignored when building module
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 // Diagnostics from this source file ignore the diagnostic state from the
anatofuz
parents:
diff changeset
23 // module.
anatofuz
parents:
diff changeset
24 void("foo" + x); // expected-warning {{adding 'int' to a string}}
anatofuz
parents:
diff changeset
25 // expected-note@-1 {{use array indexing}}
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 #pragma clang diagnostic ignored "-Wstring-plus-int"
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 // Diagnostics from the module ignore diagnostic state changes from this
anatofuz
parents:
diff changeset
30 // source file.
anatofuz
parents:
diff changeset
31 #ifdef EXPLICIT_FLAG
anatofuz
parents:
diff changeset
32 // expected-error@diag_pragma.h:7 {{adding 'long' to a string}}
anatofuz
parents:
diff changeset
33 #else
anatofuz
parents:
diff changeset
34 // expected-warning@diag_pragma.h:7 {{adding 'long' to a string}}
anatofuz
parents:
diff changeset
35 #endif
anatofuz
parents:
diff changeset
36 // expected-note@diag_pragma.h:7 {{use array indexing}}
anatofuz
parents:
diff changeset
37 f(0L); // expected-note {{instantiation of}}
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 g(0L);
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 void("bar" + x);
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 if (x = DIAG_PRAGMA_MACRO) // expected-warning {{using the result of an assignment as a condition without parentheses}} \
anatofuz
parents:
diff changeset
44 // expected-note {{place parentheses}} expected-note {{use '=='}}
anatofuz
parents:
diff changeset
45 return 0;
anatofuz
parents:
diff changeset
46 return 1;
anatofuz
parents:
diff changeset
47 }