aboutsummaryrefslogtreecommitdiff
path: root/test/Modules/module-private.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-09 02:06:17 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-09 02:06:17 +0000
commit8d267c57afb3af418ed5281b7a9bb4555d701a82 (patch)
treed38cfe3af21da70e2686d0bc251f6b0925ca0960 /test/Modules/module-private.cpp
parentf81e5a9e3f3ff80c56e4afb4fe6311a8735f36e8 (diff)
Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is declared in. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules/module-private.cpp')
-rw-r--r--test/Modules/module-private.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
new file mode 100644
index 0000000000..419946e8a5
--- /dev/null
+++ b/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