diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-10-05 21:10:08 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-10-05 21:10:08 +0000 |
commit | 279d9814e5d6693d468fed34b6333fdce4143ee4 (patch) | |
tree | e9601c8bedb0289bbf8957d89f702b02abce5f3e /clang/lib/Parse/ParseTentative.cpp | |
parent | 33ec2898d97fa21e662d4f2b87d021c9c6606343 (diff) | |
download | bcm5719-llvm-279d9814e5d6693d468fed34b6333fdce4143ee4.tar.gz bcm5719-llvm-279d9814e5d6693d468fed34b6333fdce4143ee4.zip |
Add some text from the C++ standard and additional ambiguity resolution tests.
No funcitonality change.
llvm-svn: 57136
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r-- | clang/lib/Parse/ParseTentative.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 9bd35dd1100..bd2d1069231 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -282,16 +282,24 @@ bool Parser::isCXXConditionDeclaration() { return TPR == TPResult::True(); } -/// isCXXTypeIdInParens - Assumes that a '(' was parsed and now we want to
-/// know whether the parens contain an expression or a type-id.
-/// Returns true for a type-id and false for an expression.
-/// If during the disambiguation process a parsing error is encountered,
-/// the function returns true to let the declaration parsing code handle it.
-///
-/// type-id:
+/// isCXXTypeIdInParens - Assumes that a '(' was parsed and now we want to +/// know whether the parens contain an expression or a type-id. +/// Returns true for a type-id and false for an expression. +/// If during the disambiguation process a parsing error is encountered, +/// the function returns true to let the declaration parsing code handle it. +/// +/// type-id: /// type-specifier-seq abstract-declarator[opt] /// bool Parser::isCXXTypeIdInParens() { + + // C++ 8.2p2: + // The ambiguity arising from the similarity between a function-style cast and + // a type-id can occur in different contexts. The ambiguity appears as a + // choice between a function-style cast expression and a declaration of a + // type. The resolution is that any construct that could possibly be a type-id + // in its syntactic context shall be considered a type-id. + TPResult TPR = isCXXDeclarationSpecifier(); if (TPR != TPResult::Ambiguous()) return TPR != TPResult::False(); // Returns true for TPResult::True() or @@ -706,6 +714,16 @@ Parser::TPResult Parser::TryParseDeclarationSpecifier() { /// exception-specification[opt] /// bool Parser::isCXXFunctionDeclarator() { + + // C++ 8.2p1: + // The ambiguity arising from the similarity between a function-style cast and + // a declaration mentioned in 6.8 can also occur in the context of a + // declaration. In that context, the choice is between a function declaration + // with a redundant set of parentheses around a parameter name and an object + // declaration with a function-style cast as the initializer. Just as for the + // ambiguities mentioned in 6.8, the resolution is to consider any construct + // that could possibly be a declaration a declaration. + TentativeParsingAction PA(*this); ConsumeParen(); |