Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions clang/lib/Sema/SemaCXXScopeSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,25 +779,26 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
}

if (!Found.empty()) {
const auto *ND = Found.getAsSingle<NamedDecl>();
if (::ExtendNestedNameSpecifier(*this, SS, ND, IdInfo.IdentifierLoc,
IdInfo.CCLoc)) {
const Type *T = SS.getScopeRep().getAsType();
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< QualType(T, 0) << getLangOpts().CPlusPlus;
// Recover with this type if it would be a valid nested name specifier.
return !T->getAsCanonical<TagType>();
}
if (isa<TemplateDecl>(ND)) {
ParsedType SuggestedType;
DiagnoseUnknownTypeName(IdInfo.Identifier, IdInfo.IdentifierLoc, S, &SS,
SuggestedType);
} else {
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< IdInfo.Identifier << getLangOpts().CPlusPlus;
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
Diag(ND->getLocation(), diag::note_entity_declared_at)
<< IdInfo.Identifier;
if (const auto *ND = Found.getAsSingle<NamedDecl>()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please bail out early to reduce the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

if (::ExtendNestedNameSpecifier(*this, SS, ND, IdInfo.IdentifierLoc,
IdInfo.CCLoc)) {
const Type *T = SS.getScopeRep().getAsType();
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< QualType(T, 0) << getLangOpts().CPlusPlus;
// Recover with this type if it would be a valid nested name specifier.
return !T->getAsCanonical<TagType>();
}
if (isa<TemplateDecl>(ND)) {
ParsedType SuggestedType;
DiagnoseUnknownTypeName(IdInfo.Identifier, IdInfo.IdentifierLoc, S, &SS,
SuggestedType);
} else {
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< IdInfo.Identifier << getLangOpts().CPlusPlus;
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
Diag(ND->getLocation(), diag::note_entity_declared_at)
<< IdInfo.Identifier;
}
}
} else if (SS.isSet())
Diag(IdInfo.IdentifierLoc, diag::err_no_member) << IdInfo.Identifier
Expand Down
Loading