diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-08 16:45:02 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-08 16:45:02 +0000 |
commit | eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8 (patch) | |
tree | 88e967a9d871a2ea4e6d9272c20fbc057543d2c4 /lib/Parse/ParseExpr.cpp | |
parent | 3604e3895ecd850291b518e5a82246c888ce9d0f (diff) |
Implement support for C++ nested-name-specifiers ('foo::bar::x') in the Parser side.
No Sema functionality change, just the signatures of the Action/Sema methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 4515e4b4e9..e8758e15f1 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -401,7 +401,14 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) { /// conversion-function-id [TODO] /// '~' class-name [TODO] /// template-id [TODO] +/// Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { + if (getLang().CPlusPlus) { + // Annotate typenames and C++ scope specifiers. + // Used only in C++; in C let the typedef name be handled as an identifier. + TryAnnotateTypeOrScopeToken(); + } + ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); @@ -463,17 +470,9 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { case tok::kw_false: return ParseCXXBoolLiteral(); - case tok::identifier: { - if (getLang().CPlusPlus && - Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)) { - // Handle C++ function-style cast, e.g. "T(4.5)" where T is a typedef for - // double. - goto HandleType; - } - - // primary-expression: identifier - // unqualified-id: identifier - // constant: enumeration-constant + case tok::identifier: { // primary-expression: identifier + // unqualified-id: identifier + // constant: enumeration-constant // Consume the identifier so that we can see if it is followed by a '('. // Function designators are allowed to be undeclared (C99 6.5.1p2), so we @@ -587,7 +586,8 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { case tok::kw_typeof: { if (!getLang().CPlusPlus) goto UnhandledToken; - HandleType: + case tok::annot_qualtypename: + assert(getLang().CPlusPlus && "Expected C++"); // postfix-expression: simple-type-specifier '(' expression-list[opt] ')' // DeclSpec DS; @@ -601,16 +601,11 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { return ParsePostfixExpressionSuffix(Res); } - case tok::kw_operator: { - SourceLocation OperatorLoc = Tok.getLocation(); - if (IdentifierInfo *II = MaybeParseOperatorFunctionId()) { - Res = Actions.ActOnIdentifierExpr(CurScope, OperatorLoc, *II, - Tok.is(tok::l_paren)); - // These can be followed by postfix-expr pieces. - return ParsePostfixExpressionSuffix(Res); - } - break; - } + case tok::annot_cxxscope: // [C++] id-expression: qualified-id + case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id + // template-id + Res = ParseCXXIdExpression(); + return ParsePostfixExpressionSuffix(Res); case tok::at: { SourceLocation AtLoc = ConsumeToken(); |