Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16624,6 +16624,7 @@ if (ND->isInvalidDecl()) { FrD->setInvalidDecl(); + return nullptr; } else { if (DC->isRecord()) CheckFriendAccess(ND); 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}} +};