diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-09 02:06:17 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-09 02:06:17 +0000 |
commit | 26701a437139e7643df1b02e701fa2a4cfc44a65 (patch) | |
tree | b901b0a95c2acc46390460381c253c8cb05192b1 /clang/test/Modules/module-private.cpp | |
parent | 2bd0401b04d472a155a6973f2c50905130742f45 (diff) | |
download | bcm5719-llvm-26701a437139e7643df1b02e701fa2a4cfc44a65.tar.gz bcm5719-llvm-26701a437139e7643df1b02e701fa2a4cfc44a65.zip |
Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is
declared in.
llvm-svn: 139348
Diffstat (limited to 'clang/test/Modules/module-private.cpp')
-rw-r--r-- | clang/test/Modules/module-private.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/clang/test/Modules/module-private.cpp b/clang/test/Modules/module-private.cpp new file mode 100644 index 00000000000..419946e8a54 --- /dev/null +++ b/clang/test/Modules/module-private.cpp @@ -0,0 +1,56 @@ +// RUN: mkdir -p %t +// RUN: %clang_cc1 -x c++ -emit-module -o %t/left.pcm %s -D MODULE_LEFT +// RUN: %clang_cc1 -x c++ -emit-module -o %t/right.pcm %s -D MODULE_RIGHT +// RUN: %clang_cc1 -I %t %s -verify + +#if defined(MODULE_LEFT) + +__module_private__ struct HiddenStruct { +}; + + +int &f0(int); + +template<typename T> +__module_private__ void f1(T*); + +template<typename T> +__module_private__ class vector { +}; + +vector<float> vec_float; + +typedef __module_private__ int Integer; + +#elif defined(MODULE_RIGHT) +__module_private__ double &f0(double); + +__module_private__ int hidden_var; + +inline void test_f0_in_right() { + double &dr = f0(hidden_var); +} +#else +__import_module__ left; +__import_module__ right; + +void test() { + int &ir = f0(1.0); // okay: f0() from 'right' is not visible +} + +int test_broken() { + HiddenStruct hidden; // expected-error{{use of undeclared identifier 'HiddenStruct'}} + + Integer i; // expected-error{{use of undeclared identifier 'Integer'}} + + int *ip = 0; + f1(ip); // expected-error{{use of undeclared identifier 'f1'}} + + vector<int> vec; // expected-error{{use of undeclared identifier 'vector'}} \ + // expected-error{{expected '(' for function-style cast or type construction}} \ + // expected-error{{use of undeclared identifier 'vec'}} + + return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}} +} + +#endif |