diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-05-22 10:24:42 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-05-22 10:24:42 +0000 |
commit | f58f45e6d76792df8c643ce1c6d364dce5db4826 (patch) | |
tree | 54a05a54efa7adea73c568d67e8bec7340ac8849 /lib/Parse/ParseTentative.cpp | |
parent | d974a7b72eb84cdc735b189bcea56fd37e13ebf6 (diff) |
Handle correctly a very ugly part of the C++ syntax. We cannot disambiguate between a parenthesized type-id and
a paren expression without considering the context past the parentheses.
Behold:
(T())x; - type-id
(T())*x; - type-id
(T())/x; - expression
(T()); - expression
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseTentative.cpp')
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 335a455acf..81696d6a61 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -287,7 +287,9 @@ bool Parser::isCXXConditionDeclaration() { /// type-id: /// type-specifier-seq abstract-declarator[opt] /// -bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context) { +bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) { + + isAmbiguous = false; // C++ 8.2p2: // The ambiguity arising from the similarity between a function-style cast and @@ -326,16 +328,20 @@ bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context) { if (TPR == TPResult::Ambiguous()) { // We are supposed to be inside parens, so if after the abstract declarator // we encounter a ')' this is a type-id, otherwise it's an expression. - if (Context == TypeIdInParens && Tok.is(tok::r_paren)) + if (Context == TypeIdInParens && Tok.is(tok::r_paren)) { TPR = TPResult::True(); + isAmbiguous = true; + // We are supposed to be inside a template argument, so if after // the abstract declarator we encounter a '>', '>>' (in C++0x), or // ',', this is a type-id. Otherwise, it's an expression. - else if (Context == TypeIdAsTemplateArgument && - (Tok.is(tok::greater) || Tok.is(tok::comma) || - (getLang().CPlusPlus0x && Tok.is(tok::greatergreater)))) + } else if (Context == TypeIdAsTemplateArgument && + (Tok.is(tok::greater) || Tok.is(tok::comma) || + (getLang().CPlusPlus0x && Tok.is(tok::greatergreater)))) { TPR = TPResult::True(); - else + isAmbiguous = true; + + } else TPR = TPResult::False(); } |