xref: /aosp_15_r20/external/clang/test/Modules/malformed.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // This test explicitly cd's to the test/Modules directory so that we can test
2*67e74705SXin Li // that filenames found via relative -I paths are printed correctly.
3*67e74705SXin Li //
4*67e74705SXin Li // RUN: rm -rf %t
5*67e74705SXin Li // RUN: cd %S
6*67e74705SXin Li // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="a1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-A
7*67e74705SXin Li // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="b1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-B
8*67e74705SXin Li // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="c.h" malformed.cpp 2>&1 | FileCheck %s --check-prefix=CHECK-C
9*67e74705SXin Li 
10*67e74705SXin Li #define STR2(x) #x
11*67e74705SXin Li #define STR(x) STR2(x)
12*67e74705SXin Li #include STR(HEADER)
13*67e74705SXin Li 
14*67e74705SXin Li // CHECK-A: While building module 'malformed_a'
15*67e74705SXin Li // CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}' at end of module
16*67e74705SXin Li // CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: to match this '{'
17*67e74705SXin Li //
18*67e74705SXin Li // CHECK-A: While building module 'malformed_a'
19*67e74705SXin Li // CHECK-A: {{^}}Inputs/malformed/a2.h:1:{{.*}} error: extraneous closing brace
20*67e74705SXin Li 
21*67e74705SXin Li // CHECK-B: While building module 'malformed_b'
22*67e74705SXin Li // CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: import of module 'malformed_b.b2' appears within 'S'
23*67e74705SXin Li 
test()24*67e74705SXin Li void test() { f<int>(); }
25*67e74705SXin Li // Test that we use relative paths to name files within an imported module.
26*67e74705SXin Li //
27*67e74705SXin Li // CHECK-C: In module 'c' imported from malformed.cpp:12:
28*67e74705SXin Li // CHECK-C: {{^}}Inputs/malformed/c.h:1:33: error: type 'int' cannot be used prior to '::'
29*67e74705SXin Li // CHECK-C: {{^}}malformed.cpp:[[@LINE-5]]:15: note: in instantiation of
30