1 // Clear and create directories
5 // RUN: mkdir %t/Inputs
7 // Build first header file
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
9 // RUN: cat %s >> %t/Inputs/first.h
11 // Build second header file
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
13 // RUN: cat %s >> %t/Inputs/second.h
15 // Test that each header can compile
16 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/first.h
17 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/second.h
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
28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
29 // RUN: -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs \
30 // RUN: -verify %s -std=c++11 -fblocks
32 #if !defined(FIRST) && !defined(SECOND)
39 #define ACCESS public:
41 #define ACCESS private:
44 // TODO: S1 and S2 should generate errors.
48 void (^block
)(int x
) = ^(int x
) { };
52 void (^block
)(int x
) = ^(int y
) { };
60 int (^block
)(int x
) = ^(int x
) { return x
+ 1; };
64 int (^block
)(int x
) = ^(int x
) { return x
; };
72 void run(int (^block
)(int x
));
76 void run(int (^block
)(int x
, int y
));
80 // expected-error@first.h:* {{'Blocks::S3::run' from module 'FirstModule' is not present in definition of 'Blocks::S3' in module 'SecondModule'}}
81 // expected-note@second.h:* {{declaration of 'run' does not match}}
85 int (^block)(int x) = ^(int x) { return x + x; }; \
86 void run(int (^block)(int x, int y));
88 #if defined(FIRST) || defined(SECOND)
96 #if defined(FIRST) || defined(SECOND)
103 // expected-error@second.h:* {{'Blocks::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
104 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
110 // Keep macros contained to one file.