Friend declarations are only valid inside class definitions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71489 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 7e91f5b..726080b 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2643,6 +2643,15 @@
   return DeclPtrTy::make(Decl);
 }
 
+bool Sema::ActOnFriendDecl(Scope *S, SourceLocation FriendLoc, DeclPtrTy Dcl) {
+  if (!(S->getFlags() & Scope::ClassScope)) {
+    Diag(FriendLoc, diag::err_friend_decl_outside_class);
+    return true;
+  }
+  
+  return false;
+}
+
 void Sema::SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc) {
   Decl *Dcl = dcl.getAs<Decl>();
   FunctionDecl *Fn = dyn_cast<FunctionDecl>(Dcl);