1 // RUN: rm -rf %t 2 // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map 3 // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map 4 // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify 5 // FIXME: When we have a syntax for modules in C++, use that. 6 7 @__experimental_modules_import module_private_left; 8 @__experimental_modules_import module_private_right; 9 test()10void test() { 11 int &ir = f0(1.0); // okay: f0() from 'right' is not visible 12 } 13 test_broken()14int test_broken() { 15 HiddenStruct hidden; // expected-error{{use of undeclared identifier 'HiddenStruct'}} 16 17 Integer i; // expected-error{{use of undeclared identifier 'Integer'}} 18 19 int *ip = 0; 20 f1(ip); // expected-error{{use of undeclared identifier 'f1'}} 21 22 vector<int> vec; // expected-error{{use of undeclared identifier 'vector'}} \ 23 // expected-error{{expected '(' for function-style cast or type construction}} \ 24 // expected-error{{use of undeclared identifier 'vec'}} 25 26 VisibleStruct vs; 27 vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}} 28 vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}} 29 30 return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}} 31 } 32 33 // Check for private redeclarations of public entities. 34 template<typename T> 35 class public_class_template; 36 37 template<typename T> 38 __module_private__ class public_class_template; 39 40 41 typedef int public_typedef; 42 typedef __module_private__ int public_typedef; 43 44 extern int public_var; 45 extern __module_private__ int public_var; 46 47 void public_func(); 48 __module_private__ void public_func(); 49 50 template<typename T> 51 void public_func_template(); 52 template<typename T> 53 __module_private__ void public_func_template(); 54 55 struct public_struct; 56 __module_private__ struct public_struct; 57 58 // Check for attempts to make specializations private 59 template<> __module_private__ void public_func_template<int>(); // expected-error{{template specialization cannot be declared __module_private__}} 60 61 template<typename T> 62 struct public_class { 63 struct inner_struct; 64 static int static_var; 65 66 friend __module_private__ void public_func_friend(); 67 friend __module_private__ struct public_struct_friend; 68 }; 69 70 template<> __module_private__ struct public_class<int>::inner_struct { }; // expected-error{{member specialization cannot be declared __module_private__}} 71 template<> __module_private__ int public_class<int>::static_var = 17; // expected-error{{member specialization cannot be declared __module_private__}} 72 73 template<> 74 __module_private__ struct public_class<float> { }; // expected-error{{template specialization cannot be declared __module_private__}} 75 76 template<typename T> 77 __module_private__ struct public_class<T *> { }; // expected-error{{partial specialization cannot be declared __module_private__}} 78 79 // Check for attempts to make parameters and variables with automatic 80 // storage module-private. 81 local_var_private(__module_private__ int param)82void local_var_private(__module_private__ int param) { // expected-error{{parameter 'param' cannot be declared __module_private__}} 83 __module_private__ struct Local { int x, y; } local; //expected-error{{local variable 'local' cannot be declared __module_private__}} 84 85 __module_private__ struct OtherLocal { int x; }; // expected-error{{local struct cannot be declared __module_private__}} 86 87 typedef __module_private__ int local_typedef; // expected-error{{typedef 'local_typedef' cannot be declared __module_private__}} 88 } 89 90 // Check struct size 91 struct LikeVisibleStruct { 92 int field; 93 virtual void setField(int f); 94 }; 95 96 int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1]; 97