Richard Smith | 4241314 | 2015-05-15 20:05:43 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DALLOW_NAME_LEAKAGE |
| 3 | // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DIMPORT |
| 4 | // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fmodule-name=x -I%S/Inputs/submodule-visibility -verify %s |
| 5 | // RUN: %clang_cc1 -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s |
Richard Smith | 4241314 | 2015-05-15 20:05:43 +0000 | [diff] [blame] | 6 | |
| 7 | #include "a.h" |
| 8 | #include "b.h" |
| 9 | |
| 10 | #if ALLOW_NAME_LEAKAGE |
| 11 | // expected-no-diagnostics |
| 12 | #elif IMPORT |
| 13 | // expected-error@-6 {{could not build module 'x'}} |
| 14 | #else |
| 15 | // The use of -fmodule-name=x causes us to textually include the above headers. |
| 16 | // The submodule visibility rules are still applied in this case. |
| 17 | // |
| 18 | // expected-error@b.h:1 {{declaration of 'n' must be imported from module 'x.a'}} |
| 19 | // expected-note@a.h:1 {{here}} |
| 20 | #endif |
| 21 | |
| 22 | int k = n + m; // OK, a and b are visible here. |
Richard Smith | 4df6093 | 2015-06-30 21:29:55 +0000 | [diff] [blame] | 23 | |
| 24 | #ifndef A |
| 25 | #error A is not defined |
| 26 | #endif |
| 27 | |
| 28 | #ifndef B |
| 29 | #error B is not defined |
| 30 | #endif |
Richard Smith | 6e132be | 2015-11-13 05:14:45 +0000 | [diff] [blame] | 31 | |
| 32 | // Ensure we don't compute the linkage of this struct before we find it has a |
| 33 | // typedef name for linkage purposes. |
| 34 | typedef struct { |
| 35 | int p; |
| 36 | void (*f)(int p); |
| 37 | } name_for_linkage; |