aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-12 16:11:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-12 16:11:24 +0000
commit591dc84101228dc391fca05193be5870ec661edc (patch)
tree17224f60ad66eae84ea1502053b97bbe2f8412c8
parentf3a762a8de396af471f35b77f6897989867c898e (diff)
Allow __module_private__ on fields
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139499 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/Modules/module-private.cpp10
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d6137e5dba..432354cc7d 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -8079,6 +8079,9 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
if (NewFD->isInvalidDecl())
Record->setInvalidDecl();
+ if (D.getDeclSpec().isModulePrivateSpecified())
+ NewFD->setModulePrivate();
+
if (NewFD->isInvalidDecl() && PrevDecl) {
// Don't introduce NewFD into scope; there's already something
// with the same name in the same scope.
@@ -8556,6 +8559,9 @@ Decl *Sema::ActOnIvar(Scope *S,
if (getLangOptions().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
NewID->setInvalidDecl();
+ if (D.getDeclSpec().isModulePrivateSpecified())
+ NewID->setModulePrivate();
+
if (II) {
// FIXME: When interfaces are DeclContexts, we'll need to add
// these to the interface.
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
index 4421538622..949d795865 100644
--- a/test/Modules/module-private.cpp
+++ b/test/Modules/module-private.cpp
@@ -40,6 +40,12 @@ __module_private__ int hidden_var;
inline void test_f0_in_right() {
double &dr = f0(hidden_var);
}
+
+struct VisibleStruct {
+ __module_private__ int field;
+ __module_private__ void setField(int f);
+};
+
#else
__import_module__ left;
__import_module__ right;
@@ -60,6 +66,10 @@ int test_broken() {
// expected-error{{expected '(' for function-style cast or type construction}} \
// expected-error{{use of undeclared identifier 'vec'}}
+ VisibleStruct vs;
+ vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}}
+ vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}}
+
return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}}
}