Skip to content

Commit a1514e1

Browse files
committed
[FOLD] TransformOverloadExprDecls filters template names
1 parent a5113ca commit a1514e1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
10151015
ActOnMemberAccessExtraArgs *ExtraArgs) {
10161016

10171017
if (R.wasNotFoundInCurrentInstantiation() ||
1018-
(SS.isValid() && !computeDeclContext(SS, false)) ||
1019-
(R.isUnresolvableResult() && R.isClassLookup() && R.getNamingClass()->isDependentContext())) {
1018+
(SS.isValid() && !computeDeclContext(SS, false))) {
10201019
return ActOnDependentMemberExpr(BaseExpr, BaseExprType,
10211020
IsArrow, OpLoc,
10221021
SS, TemplateKWLoc, FirstQualifierInScope,

clang/lib/Sema/TreeTransform.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12938,6 +12938,26 @@ bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old,
1293812938
// Resolve a kind, but don't do any further analysis. If it's
1293912939
// ambiguous, the callee needs to deal with it.
1294012940
R.resolveKind();
12941+
12942+
if (Old->hasTemplateKeyword() && !R.empty()) {
12943+
NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
12944+
getSema().FilterAcceptableTemplateNames(R,
12945+
/*AllowFunctionTemplates=*/true,
12946+
/*AllowDependent=*/true);
12947+
if (R.empty()) {
12948+
// If a 'template' keyword was used, a lookup that finds only non-template
12949+
// names is an error.
12950+
getSema().Diag(R.getNameLoc(), diag::err_template_kw_refers_to_non_template)
12951+
<< R.getLookupName()
12952+
<< Old->getQualifierLoc().getSourceRange()
12953+
<< Old->hasTemplateKeyword()
12954+
<< Old->getTemplateKeywordLoc();
12955+
getSema().Diag(FoundDecl->getLocation(), diag::note_template_kw_refers_to_non_template)
12956+
<< R.getLookupName();
12957+
return true;
12958+
}
12959+
}
12960+
1294112961
return false;
1294212962
}
1294312963

0 commit comments

Comments
 (0)