diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-12-26 15:00:45 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-12-26 15:00:45 +0000 |
commit | 70316a065bcf11c88143e22c88d530ebd320832f (patch) | |
tree | e74e3cd758435693f175a7bea8892c69db747b30 /lib/Parse/ParseDecl.cpp | |
parent | 4bcd44d3b38a9aece40142ea54c07288eb0517f6 (diff) |
Add support for out-of-line definitions of conversion functions and member operators
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e3fd6961bf..23c0c61517 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1514,7 +1514,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // If this identifier is followed by a '<', we may have a template-id. DeclTy *Template; - if (getLang().CPlusPlus && NextToken().is(tok::less) && + if (NextToken().is(tok::less) && (Template = Actions.isTemplateName(*Tok.getIdentifierInfo(), CurScope))) { IdentifierInfo *II = Tok.getIdentifierInfo(); @@ -1525,8 +1525,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { } // If this identifier is the name of the current class, it's a // constructor name. - else if (getLang().CPlusPlus && - Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope)) + else if (Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope)) D.setConstructor(Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope), Tok.getLocation()); @@ -1535,9 +1534,21 @@ void Parser::ParseDirectDeclarator(Declarator &D) { D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); ConsumeToken(); goto PastIdentifier; - } + } else if (Tok.is(tok::kw_operator)) { + SourceLocation OperatorLoc = Tok.getLocation(); - if (Tok.is(tok::tilde)) { + // First try the name of an overloaded operator + if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) { + D.setOverloadedOperator(Op, OperatorLoc); + } else { + // This must be a conversion function (C++ [class.conv.fct]). + if (TypeTy *ConvType = ParseConversionFunctionId()) + D.setConversionFunction(ConvType, OperatorLoc); + else + D.SetIdentifier(0, Tok.getLocation()); + } + goto PastIdentifier; + } else if (Tok.is(tok::tilde)) { // This should be a C++ destructor. SourceLocation TildeLoc = ConsumeToken(); if (Tok.is(tok::identifier)) { @@ -1561,22 +1572,6 @@ void Parser::ParseDirectDeclarator(Declarator &D) { goto PastIdentifier; } } - - if (Tok.is(tok::kw_operator)) { - SourceLocation OperatorLoc = Tok.getLocation(); - - // First try the name of an overloaded operator - if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) { - D.setOverloadedOperator(Op, OperatorLoc); - } else { - // This must be a conversion function (C++ [class.conv.fct]). - if (TypeTy *ConvType = ParseConversionFunctionId()) - D.setConversionFunction(ConvType, OperatorLoc); - else - D.SetIdentifier(0, Tok.getLocation()); - } - goto PastIdentifier; - } } // If we reached this point, we are either in C/ObjC or the token didn't |