Skip to content

Commit b3e6fde

Browse files
committed
[FOLD]
1 parent 7a28a5b commit b3e6fde

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7716,6 +7716,14 @@ NamedDecl *Sema::ActOnVariableDeclarator(
77167716
? diag::warn_cxx11_compat_variable_template
77177717
: diag::ext_variable_template);
77187718
}
7719+
7720+
if (CurContext->isRecord() && SC != SC_Static && (IsVariableTemplate || IsPartialSpecialization)) {
7721+
// There is no such thing as a member field template.
7722+
Diag(D.getIdentifierLoc(), diag::err_template_member)
7723+
<< II << TemplateParams->getSourceRange();
7724+
// Recover by pretending this is a static data member template.
7725+
SC = SC_Static;
7726+
}
77197727
}
77207728
} else {
77217729
// Check that we can declare a member specialization here.

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,9 +3489,9 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
34893489
break;
34903490
}
34913491

3492-
bool isInstField = ((DS.getStorageClassSpec() == DeclSpec::SCS_unspecified ||
3492+
bool isInstField = (DS.getStorageClassSpec() == DeclSpec::SCS_unspecified ||
34933493
DS.getStorageClassSpec() == DeclSpec::SCS_mutable) &&
3494-
!isFunc);
3494+
!isFunc && TemplateParameterLists.empty();
34953495

34963496
if (DS.hasConstexprSpecifier() && isInstField) {
34973497
SemaDiagnosticBuilder B =
@@ -3541,6 +3541,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
35413541

35423542
IdentifierInfo *II = Name.getAsIdentifierInfo();
35433543

3544+
#if 0
35443545
// Member field could not be with "template" keyword.
35453546
// So TemplateParameterLists should be empty in this case.
35463547
if (TemplateParameterLists.size()) {
@@ -3561,6 +3562,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
35613562
}
35623563
return nullptr;
35633564
}
3565+
#endif
35643566

35653567
if (D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId) {
35663568
Diag(D.getIdentifierLoc(), diag::err_member_with_template_arguments)

0 commit comments

Comments
 (0)