Fix the recently-added warning about 'typename' and 'template'
disambiguation keywords outside of templates in C++98/03. Previously,
the warning would fire when the associated nested-name-specifier was
not dependent, but that was a misreading of the C++98/03 standard:
now, we complain only when we're outside of any template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106161 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 586dac6..843baa2 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -165,7 +165,8 @@
// Commit to parsing the template-id.
TPA.Commit();
TemplateTy Template
- = Actions.ActOnDependentTemplateName(TemplateKWLoc, SS, TemplateName,
+ = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, SS,
+ TemplateName,
ObjectType, EnteringContext);
if (!Template)
return true;
@@ -319,7 +320,8 @@
<< II.getName()
<< FixItHint::CreateInsertion(Tok.getLocation(), "template ");
- Template = Actions.ActOnDependentTemplateName(Tok.getLocation(), SS,
+ Template = Actions.ActOnDependentTemplateName(CurScope,
+ Tok.getLocation(), SS,
TemplateName, ObjectType,
EnteringContext);
if (!Template.get())
@@ -1011,7 +1013,7 @@
case UnqualifiedId::IK_OperatorFunctionId:
case UnqualifiedId::IK_LiteralOperatorId:
if (AssumeTemplateId) {
- Template = Actions.ActOnDependentTemplateName(TemplateKWLoc, SS,
+ Template = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, SS,
Id, ObjectType,
EnteringContext);
TNK = TNK_Dependent_template_name;
@@ -1042,8 +1044,8 @@
Diag(Id.StartLocation, diag::err_missing_dependent_template_keyword)
<< Name
<< FixItHint::CreateInsertion(Id.StartLocation, "template ");
- Template = Actions.ActOnDependentTemplateName(TemplateKWLoc, SS,
- Id, ObjectType,
+ Template = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc,
+ SS, Id, ObjectType,
EnteringContext);
TNK = TNK_Dependent_template_name;
if (!Template.get())
@@ -1067,7 +1069,7 @@
bool MemberOfUnknownSpecialization;
TemplateName.setIdentifier(Name, NameLoc);
if (ObjectType) {
- Template = Actions.ActOnDependentTemplateName(TemplateKWLoc, SS,
+ Template = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, SS,
TemplateName, ObjectType,
EnteringContext);
TNK = TNK_Dependent_template_name;
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 5d248f1..ec0e31e 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -916,9 +916,9 @@
// template argument.
if (isEndOfTemplateArgument(Tok)) {
TemplateTy Template
- = Actions.ActOnDependentTemplateName(TemplateLoc, SS, Name,
- /*ObjectType=*/0,
- /*EnteringContext=*/false);
+ = Actions.ActOnDependentTemplateName(CurScope, TemplateLoc, SS, Name,
+ /*ObjectType=*/0,
+ /*EnteringContext=*/false);
if (Template.get())
return ParsedTemplateArgument(SS, Template, Name.StartLocation);
}
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 2968970..225a793 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -919,7 +919,8 @@
TypeResult Ty;
if (Tok.is(tok::identifier)) {
// FIXME: check whether the next token is '<', first!
- Ty = Actions.ActOnTypenameType(TypenameLoc, SS, *Tok.getIdentifierInfo(),
+ Ty = Actions.ActOnTypenameType(CurScope, TypenameLoc, SS,
+ *Tok.getIdentifierInfo(),
Tok.getLocation());
} else if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId
@@ -934,7 +935,8 @@
assert(Tok.is(tok::annot_typename) &&
"AnnotateTemplateIdTokenAsType isn't working properly");
if (Tok.getAnnotationValue())
- Ty = Actions.ActOnTypenameType(TypenameLoc, SS, SourceLocation(),
+ Ty = Actions.ActOnTypenameType(CurScope, TypenameLoc, SS,
+ SourceLocation(),
Tok.getAnnotationValue());
else
Ty = true;