Modify an assert to capture the restriction on friend declarations more
accurately.  Prevents the assert from triggering incorrectly when friending 
functions first declared in extern "C" contexts.  Fixes bug 4757.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index ee6238c..61f0ce8 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2390,7 +2390,8 @@
   FunctionDecl *NewFD;
   if (isFriend) {
     // DC is the namespace in which the function is being declared.
-    assert(DC->isFileContext() || D.getCXXScopeSpec().isSet());
+    assert((DC->isFileContext() || PrevDecl) && "previously-undeclared "
+           "friend function being created in a non-namespace context");
 
     // C++ [class.friend]p5
     //   A function can be defined in a friend declaration of a