Home | History | Annotate | Download | only in Modules
      1 // RUN: rm -rf %t
      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
      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 (at) b.h:1 {{declaration of 'n' must be imported from module 'x.a'}}
     19 // expected-note (at) a.h:1 {{here}}
     20 #endif
     21 
     22 int k = n + m; // OK, a and b are visible here.
     23 
     24 #ifndef A
     25 #error A is not defined
     26 #endif
     27 
     28 #ifndef B
     29 #error B is not defined
     30 #endif
     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;
     38