Skip to content

Commit 6cde665

Browse files
committed
[FOLD] TransformOverloadExprDecls filters template names
1 parent 2b67b4b commit 6cde665

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
@@ -12930,6 +12930,26 @@ bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old,
1293012930
// Resolve a kind, but don't do any further analysis. If it's
1293112931
// ambiguous, the callee needs to deal with it.
1293212932
R.resolveKind();
12933+
12934+
if (Old->hasTemplateKeyword() && !R.empty()) {
12935+
NamedDecl *FoundDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
12936+
getSema().FilterAcceptableTemplateNames(R,
12937+
/*AllowFunctionTemplates=*/true,
12938+
/*AllowDependent=*/true);
12939+
if (R.empty()) {
12940+
// If a 'template' keyword was used, a lookup that finds only non-template
12941+
// names is an error.
12942+
getSema().Diag(R.getNameLoc(), diag::err_template_kw_refers_to_non_template)
12943+
<< R.getLookupName()
12944+
<< Old->getQualifierLoc().getSourceRange()
12945+
<< Old->hasTemplateKeyword()
12946+
<< Old->getTemplateKeywordLoc();
12947+
getSema().Diag(FoundDecl->getLocation(), diag::note_template_kw_refers_to_non_template)
12948+
<< R.getLookupName();
12949+
return true;
12950+
}
12951+
}
12952+
1293312953
return false;
1293412954
}
1293512955

0 commit comments

Comments
 (0)