Friends cannot be declared module-private

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139411 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp
index 55964d5..531e7a5 100644
--- a/lib/Sema/DeclSpec.cpp
+++ b/lib/Sema/DeclSpec.cpp
@@ -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.