diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-23 22:44:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-23 22:44:42 +0000 |
commit | a8bc8c9e9ba5bffebde00340786fe8542469c435 (patch) | |
tree | 75be85d4dd770d5f44b6c43b54d38747e8de8e8b /lib/Parse/ParseTentative.cpp | |
parent | c32647d111e516593b9ba242cad7b8ff4016c155 (diff) |
Implement parsing of function parameter packs and non-type template
parameter packs (C++0x [dcl.fct]p13), including disambiguation between
unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for
cases like
void f(T...)
where T may or may not contain unexpanded parameter packs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122520 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseTentative.cpp')
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 81abdb884a..fc57b4086b 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -461,6 +461,7 @@ bool Parser::isCXX0XAttributeSpecifier (bool CheckClosing, /// abstract-declarator: /// ptr-operator abstract-declarator[opt] /// direct-abstract-declarator +/// ... /// /// direct-abstract-declarator: /// direct-abstract-declarator[opt] @@ -483,7 +484,7 @@ bool Parser::isCXX0XAttributeSpecifier (bool CheckClosing, /// 'volatile' /// /// declarator-id: -/// id-expression +/// '...'[opt] id-expression /// /// id-expression: /// unqualified-id @@ -522,7 +523,9 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, // direct-declarator: // direct-abstract-declarator: - + if (Tok.is(tok::ellipsis)) + ConsumeToken(); + if ((Tok.is(tok::identifier) || (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::identifier))) && mayHaveIdentifier) { @@ -566,6 +569,10 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, while (1) { TPResult TPR(TPResult::Ambiguous()); + // abstract-declarator: ... + if (Tok.is(tok::ellipsis)) + ConsumeToken(); + if (Tok.is(tok::l_paren)) { // Check whether we have a function declarator or a possible ctor-style // initializer that follows the declarator. Note that ctor-style @@ -1165,8 +1172,8 @@ Parser::TPResult Parser::TryParseParameterDeclarationClause() { if (Tok.is(tok::equal)) { // '=' assignment-expression // Parse through assignment-expression. - tok::TokenKind StopToks[3] ={ tok::comma, tok::ellipsis, tok::r_paren }; - if (!SkipUntil(StopToks, 3, true/*StopAtSemi*/, true/*DontConsume*/)) + tok::TokenKind StopToks[2] ={ tok::comma, tok::r_paren }; + if (!SkipUntil(StopToks, 2, true/*StopAtSemi*/, true/*DontConsume*/)) return TPResult::Error(); } |