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 | 1dc9826a46ce64f827b46c4dc0e18710736b4cc4 (patch) | |
tree | 12008c27a8c84748612ff42a6a4b623bd5f8fff6 /clang/lib/Parse/ParseDecl.cpp | |
parent | 88b53663fbbd0e697f277f61ffea7bb61b563c98 (diff) | |
download | bcm5719-llvm-1dc9826a46ce64f827b46c4dc0e18710736b4cc4.tar.gz bcm5719-llvm-1dc9826a46ce64f827b46c4dc0e18710736b4cc4.zip |
Add support for out-of-line definitions of conversion functions and member operators
llvm-svn: 61442
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index e3fd6961bf8..23c0c61517d 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/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 |