blob: 345ae155bb323795a45670f0d99e8178c2667395 [file] [log] [blame]
Richard Smith42413142015-05-15 20:05:43 +00001// RUN: rm -rf %t
Richard Smith47972af2015-06-16 00:08:24 +00002// 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 Smith42413142015-05-15 20:05:43 +00006
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
22int k = n + m; // OK, a and b are visible here.
Richard Smith4df60932015-06-30 21:29:55 +000023
24#ifndef A
25#error A is not defined
26#endif
27
28#ifndef B
29#error B is not defined
30#endif
Richard Smith6e132be2015-11-13 05:14:45 +000031
32// Ensure we don't compute the linkage of this struct before we find it has a
33// typedef name for linkage purposes.
34typedef struct {
35 int p;
36 void (*f)(int p);
37} name_for_linkage;