diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-03 23:16:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-03 23:16:33 +0000 |
commit | 014e88d94ff83e3aad4e33b16413a2d1817ec208 (patch) | |
tree | 30e9a9f52bb5682b9a948d82b65c95e6d309410a /lib/Parse/ParseExprCXX.cpp | |
parent | f758dc0812e7d0a846d2e07047a9c675e2ecb191 (diff) |
Parsing and semantic analysis for template-ids that name overloaded
operators, e.g.,
operator+<int>
which now works in declarators, id-expressions, and member access
expressions. This commit only implements the non-dependent case, where
we can resolve the template-id to an actual declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index d5314c0d4e..d0e2f70319 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -125,10 +125,10 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, break; } + UnqualifiedId TemplateName; + TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); TemplateTy Template - = Actions.ActOnDependentTemplateName(TemplateKWLoc, - *Tok.getIdentifierInfo(), - Tok.getLocation(), SS, + = Actions.ActOnDependentTemplateName(TemplateKWLoc, SS, TemplateName, ObjectType); if (!Template) break; @@ -220,9 +220,10 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, // type-name '<' if (Next.is(tok::less)) { TemplateTy Template; - if (TemplateNameKind TNK = Actions.isTemplateName(CurScope, II, - Tok.getLocation(), - &SS, + UnqualifiedId TemplateName; + TemplateName.setIdentifier(&II, Tok.getLocation()); + if (TemplateNameKind TNK = Actions.isTemplateName(CurScope, SS, + TemplateName, ObjectType, EnteringContext, Template)) { @@ -741,45 +742,30 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, TemplateNameKind TNK = TNK_Non_template; switch (Id.getKind()) { case UnqualifiedId::IK_Identifier: - TNK = Actions.isTemplateName(CurScope, *Id.Identifier, Id.StartLocation, - &SS, ObjectType, EnteringContext, Template); + case UnqualifiedId::IK_OperatorFunctionId: + TNK = Actions.isTemplateName(CurScope, SS, Id, ObjectType, EnteringContext, + Template); break; - case UnqualifiedId::IK_OperatorFunctionId: { - // FIXME: Temporary hack: warn that we are completely ignoring the - // template arguments for now. - // Parse the enclosed template argument list and throw it away. - SourceLocation LAngleLoc, RAngleLoc; - TemplateArgList TemplateArgs; - TemplateArgIsTypeList TemplateArgIsType; - TemplateArgLocationList TemplateArgLocations; - if (ParseTemplateIdAfterTemplateName(Template, Id.StartLocation, - &SS, true, LAngleLoc, - TemplateArgs, - TemplateArgIsType, - TemplateArgLocations, - RAngleLoc)) - return true; - - Diag(Id.StartLocation, diag::warn_operator_template_id_ignores_args) - << SourceRange(LAngleLoc, RAngleLoc); - break; - } - - case UnqualifiedId::IK_ConstructorName: - TNK = Actions.isTemplateName(CurScope, *Name, NameLoc, &SS, ObjectType, + case UnqualifiedId::IK_ConstructorName: { + UnqualifiedId TemplateName; + TemplateName.setIdentifier(Name, NameLoc); + TNK = Actions.isTemplateName(CurScope, SS, TemplateName, ObjectType, EnteringContext, Template); break; + } - case UnqualifiedId::IK_DestructorName: + case UnqualifiedId::IK_DestructorName: { + UnqualifiedId TemplateName; + TemplateName.setIdentifier(Name, NameLoc); if (ObjectType) { - Template = Actions.ActOnDependentTemplateName(SourceLocation(), *Name, - NameLoc, SS, ObjectType); + Template = Actions.ActOnDependentTemplateName(SourceLocation(), SS, + TemplateName, ObjectType); TNK = TNK_Dependent_template_name; if (!Template.get()) return true; } else { - TNK = Actions.isTemplateName(CurScope, *Name, NameLoc, &SS, ObjectType, + TNK = Actions.isTemplateName(CurScope, SS, TemplateName, ObjectType, EnteringContext, Template); if (TNK == TNK_Non_template && Id.DestructorName == 0) { @@ -794,6 +780,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, } } break; + } default: return false; @@ -824,9 +811,12 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, if (Id.getKind() == UnqualifiedId::IK_Identifier) { TemplateId->Name = Id.Identifier; + TemplateId->Operator = OO_None; TemplateId->TemplateNameLoc = Id.StartLocation; } else { - // FIXME: Handle IK_OperatorFunctionId + TemplateId->Name = 0; + TemplateId->Operator = Id.OperatorFunctionId.Operator; + TemplateId->TemplateNameLoc = Id.StartLocation; } TemplateId->Template = Template.getAs<void*>(); |