Index: clang/lib/Parse/ParseCXXInlineMethods.cpp =================================================================== --- clang/lib/Parse/ParseCXXInlineMethods.cpp +++ clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -403,7 +403,7 @@ if (Tok.is(tok::eof) && Tok.getEofData() == Param) ConsumeAnyToken(); - } else if (HasUnparsed) { + } else if (HasUnparsed && !LM.Method->isInvalidDecl()) { assert(Param->hasInheritedDefaultArg()); FunctionDecl *Old = cast(LM.Method)->getPreviousDecl(); ParmVarDecl *OldParam = Old->getParamDecl(I); Index: clang/test/CodeGenCXX/invalid-decl.cpp =================================================================== --- /dev/null +++ clang/test/CodeGenCXX/invalid-decl.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm %s -verify +class test1 { + template friend int bar(bool = true) { // expected-note {{previous declaration is here}} + return 1; + } + template friend int bar(bool); // expected-error {{friend declaration specifying a default argument must be the only declaration}} +}; + +class test2 { + friend int bar(bool = true) // expected-note {{previous declaration is here}} + { + return 1; + } + friend int bar(bool); // expected-error {{friend declaration specifying a default argument must be the only declaration}} +};