150
|
1 // Clear and create directories
|
|
2 // RUN: rm -rf %t
|
|
3 // RUN: mkdir %t
|
|
4 // RUN: mkdir %t/cache
|
|
5 // RUN: mkdir %t/Inputs
|
|
6
|
|
7 // Build first header file
|
|
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
|
|
9 // RUN: cat %s >> %t/Inputs/first.h
|
|
10
|
|
11 // Build second header file
|
|
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
|
|
13 // RUN: cat %s >> %t/Inputs/second.h
|
|
14
|
|
15 // Test that each header can compile
|
|
16 // RUN: %clang_cc1 -fsyntax-only -x c++ %t/Inputs/first.h -cl-std=CL2.0
|
|
17 // RUN: %clang_cc1 -fsyntax-only -x c++ %t/Inputs/second.h -cl-std=CL2.0
|
|
18
|
|
19 // Build module map file
|
|
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.map
|
|
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.map
|
|
22 // RUN: echo "}" >> %t/Inputs/module.map
|
|
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.map
|
|
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.map
|
|
25 // RUN: echo "}" >> %t/Inputs/module.map
|
|
26
|
|
27 // Run test
|
|
28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -cl-std=CL2.0
|
|
29
|
|
30 #if !defined(FIRST) && !defined(SECOND)
|
|
31 #include "first.h"
|
|
32 #include "second.h"
|
|
33 #endif
|
|
34
|
|
35
|
|
36 #if defined(FIRST)
|
|
37 void invalid1() {
|
|
38 typedef read_only pipe int x;
|
|
39 }
|
|
40 void invalid2() {
|
|
41 typedef read_only pipe int x;
|
|
42 }
|
|
43 void valid() {
|
|
44 typedef read_only pipe int x;
|
|
45 typedef write_only pipe int y;
|
|
46 typedef read_write pipe int z;
|
|
47 }
|
|
48 #elif defined(SECOND)
|
|
49 void invalid1() {
|
|
50 typedef write_only pipe int x;
|
|
51 }
|
|
52 void invalid2() {
|
|
53 typedef read_only pipe float x;
|
|
54 }
|
|
55 void valid() {
|
|
56 typedef read_only pipe int x;
|
|
57 typedef write_only pipe int y;
|
|
58 typedef read_write pipe int z;
|
|
59 }
|
|
60 #else
|
|
61 void run() {
|
|
62 invalid1();
|
|
63 // expected-error@second.h:* {{'invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
|
|
64 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
|
|
65 invalid2();
|
|
66 // expected-error@second.h:* {{'invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
|
|
67 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
|
|
68 valid();
|
|
69 }
|
|
70 #endif
|
|
71
|
|
72
|
|
73 // Keep macros contained to one file.
|
|
74 #ifdef FIRST
|
|
75 #undef FIRST
|
|
76 #endif
|
|
77
|
|
78 #ifdef SECOND
|
|
79 #undef SECOND
|
|
80 #endif
|