[cfe-commits] r139411 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Sema/DeclSpec.cpp test/Modules/module-private.cpp
Douglas Gregor
dgregor at apple.com
Fri Sep 9 14:14:30 PDT 2011
Author: dgregor
Date: Fri Sep 9 16:14:29 2011
New Revision: 139411
URL: http://llvm.org/viewvc/llvm-project?rev=139411&view=rev
Log:
Friends cannot be declared module-private
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/test/Modules/module-private.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=139411&r1=139410&r2=139411&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep 9 16:14:29 2011
@@ -582,6 +582,8 @@
"expected a module name after '__import_module__'">;
def err_module_expected_semi : Error<
"expected a semicolon name after module name">;
+def err_module_private_friend : Error<
+ "friend cannot be declared __module_private__">;
}
} // end of Parser diagnostics
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=139411&r1=139410&r2=139411&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Fri Sep 9 16:14:29 2011
@@ -899,8 +899,15 @@
ClearStorageClassSpecs();
}
- assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
+ // A friend cannot be specified as module-private.
+ if (isFriendSpecified() && isModulePrivateSpecified()) {
+ Diag(D, ModulePrivateLoc, diag::err_module_private_friend)
+ << FixItHint::CreateRemoval(ModulePrivateLoc);
+ ModulePrivateLoc = SourceLocation();
+ }
+ assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
+
// Okay, now we can infer the real type.
// TODO: return "auto function" and other bad things based on the real type.
Modified: cfe/trunk/test/Modules/module-private.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-private.cpp?rev=139411&r1=139410&r2=139411&view=diff
==============================================================================
--- cfe/trunk/test/Modules/module-private.cpp (original)
+++ cfe/trunk/test/Modules/module-private.cpp Fri Sep 9 16:14:29 2011
@@ -95,6 +95,9 @@
struct public_class {
struct inner_struct;
static int static_var;
+
+ friend __module_private__ void public_func(); // expected-error{{friend cannot be declared __module_private__}}
+ friend __module_private__ struct public_struct; // expected-error{{friend cannot be declared __module_private__}}
};
template<> __module_private__ struct public_class<int>::inner_struct { }; // expected-error{{member specialization cannot be declared __module_private__}}
More information about the cfe-commits
mailing list