? cast<NamedDecl>(FunctionTemplate)
: NewFD);
- if (isFriend && D.isRedeclaration()) {
+ if (isFriend && NewFD->getPreviousDecl()) {
AccessSpecifier Access = AS_public;
if (!NewFD->isInvalidDecl())
Access = NewFD->getPreviousDecl()->getAccess();
NewFD->setPreviousDeclaration(cast<FunctionDecl>(OldDecl));
if (isa<CXXMethodDecl>(NewFD))
NewFD->setAccess(OldDecl->getAccess());
- } else {
- Redeclaration = false;
}
}
}
// template in the translation unit.
if (functionDeclHasDefaultArgument(FD)) {
// We can't look at FD->getPreviousDecl() because it may not have been set
- // if we're in a dependent context. If we get this far with a non-empty
- // Previous set, we must have a valid previous declaration of this
- // function.
- if (!Previous.empty()) {
+ // if we're in a dependent context. If the function is known to be a
+ // redeclaration, we will have narrowed Previous down to the right decl.
+ if (D.isRedeclaration()) {
Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
Diag(Previous.getRepresentativeDecl()->getLocation(),
diag::note_previous_declaration);
X *q = p;
}
}
+
+namespace default_arg {
+ void f();
+ void f(void*); // expected-note {{previous}}
+ struct X {
+ friend void f(int a, int b = 0) {}
+ friend void f(void *p = 0) {} // expected-error {{must be the only}}
+ };
+}