Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 184825)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -4267,6 +4267,10 @@
   "out-of-line definition of %0 from class %1 without definition">;
 def err_member_def_does_not_match : Error<
   "out-of-line definition of %0 does not match any declaration in %1">;
+def err_friend_decl_with_def_arg_must_be_def : Error<
+  "friend declaration specifying a default argument must be a definition">;
+def err_friend_decl_with_def_arg_redeclared : Error<
+  "friend declaration specifying a default argument must be the only declaration">;
 def err_friend_decl_does_not_match : Error<
   "friend declaration of %0 does not match any declaration in %1">;
 def err_member_def_does_not_match_suggest : Error<
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp	(revision 184825)
+++ lib/Sema/SemaDeclCXX.cpp	(working copy)
@@ -404,6 +404,15 @@
   }
 }
 
+static bool functionDeclHasDefaultArgument(const FunctionDecl *FD) {
+  for (unsigned NumParams = FD->getNumParams(); NumParams > 0; --NumParams) {
+    const ParmVarDecl *PVD = FD->getParamDecl(NumParams-1);
+    if (PVD->hasDefaultArg() && !PVD->hasInheritedDefaultArg())
+      return true;
+  }
+  return false;
+}
+
 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
 /// function, once we already know that they have the same
 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
@@ -578,6 +587,18 @@
     Invalid = true;
   }
 
+  // C++11 [dcl.fct.default]p4: If a friend declaration specifies a default
+  // argument expression, that declaration shall be a deﬁnition and shall be
+  // the only declaration of the function or function template in the
+  // translation unit.
+  if (!isa<CXXMethodDecl>(Old) &&
+      Old->getFriendObjectKind() == Decl::FOK_Undeclared &&
+      functionDeclHasDefaultArgument(Old)) {
+      Diag(New->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
+      Diag(Old->getLocation(), diag::note_previous_declaration);
+      Invalid = true;
+    }
+
   if (CheckEquivalentExceptionSpec(Old, New))
     Invalid = true;
 
@@ -11377,6 +11398,18 @@
     else
       FD = cast<FunctionDecl>(ND);
 
+    // C++11 [dcl.fct.default]p4: If a friend declaration specifies a
+    // default argument expression, that declaration shall be a definition
+    // and shall be the only declaration of the function or function
+    // template in the translation unit.
+    if (!isa<CXXMethodDecl>(FD) && functionDeclHasDefaultArgument(FD)) {
+      if (FunctionDecl *OldFD = FD->getPreviousDecl()) {
+        Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
+        Diag(OldFD->getLocation(), diag::note_previous_declaration);
+      } else if (!D.isFunctionDefinition())
+        Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
+    }
+
     // Mark templated-scope function declarations as unsupported.
     if (FD->getNumTemplateParameterLists())
       FrD->setUnsupportedFriend(true);
Index: test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp
===================================================================
--- test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp	(revision 184825)
+++ test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp	(working copy)
@@ -4,6 +4,6 @@
 
 namespace nm {
   struct str {
-    friend int foo(int arg = 0);
+    friend void foo(int arg = 0) {};
   };
 }
Index: test/CXX/drs/dr1xx.cpp
===================================================================
--- test/CXX/drs/dr1xx.cpp	(revision 184825)
+++ test/CXX/drs/dr1xx.cpp	(working copy)
@@ -357,25 +357,33 @@
   };
 }
 
-namespace dr136 { // dr136: no
-  void f(int, int, int = 0);
-  void g(int, int, int);
+namespace dr136 { // dr136: yes
+  void f(int, int, int = 0); // expected-note {{previous declaration is here}}
+  void g(int, int, int); // expected-note {{previous declaration is here}}
   struct A {
-    // FIXME: These declarations of f, g, and h are invalid.
-    friend void f(int, int = 0, int);
-    friend void g(int, int, int = 0);
-    friend void h(int, int, int = 0);
-    friend void i(int, int, int = 0) {}
+    friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
+    friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
+    friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
+    friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}}
     friend void j(int, int, int = 0) {}
     operator int();
   };
-  // FIXME: This declaration of i is invalid.
-  void i(int, int, int);
+  void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
   void q() {
     j(A(), A()); // ok, has default argument
   }
-  // FIXME: Also test extern "C" friends and default arguments from other
-  // namespaces?
+  extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}}
+  namespace NSA {
+  struct A {
+    friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \
+                                                  // expected-note {{previous declaration is here}}
+  };
+  }
+  namespace NSB {
+  struct A {
+    friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
+  };
+  }
 }
 
 namespace dr137 { // dr137: yes
Index: test/SemaCXX/friend.cpp
===================================================================
--- test/SemaCXX/friend.cpp	(revision 184825)
+++ test/SemaCXX/friend.cpp	(working copy)
@@ -44,7 +44,7 @@
 // PR5134
 namespace test3 {
   class Foo {
-    friend const int getInt(int inInt = 0);
+    friend const int getInt(int inInt = 0) {}
 
   };
 }
