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/ParseDecl.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/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 53cccc0819..f627b2c9f4 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -2819,7 +2819,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, /// [C++] declarator-id /// /// declarator-id: [C++ 8] -/// id-expression +/// '...'[opt] id-expression /// '::'[opt] nested-name-specifier[opt] type-name /// /// id-expression: [C++ 5.1] @@ -2849,6 +2849,21 @@ void Parser::ParseDirectDeclarator(Declarator &D) { DeclScopeObj.EnterDeclaratorScope(); } + // C++0x [dcl.fct]p14: + // There is a syntactic ambiguity when an ellipsis occurs at the end + // of a parameter-declaration-clause without a preceding comma. In + // this case, the ellipsis is parsed as part of the + // abstract-declarator if the type of the parameter names a template + // parameter pack that has not been expanded; otherwise, it is parsed + // as part of the parameter-declaration-clause. + if (Tok.is(tok::ellipsis) && + !((D.getContext() == Declarator::PrototypeContext || + D.getContext() == Declarator::BlockLiteralContext) && + getCurScope()->getTemplateParamParent() && + NextToken().is(tok::r_paren) && + !Actions.containsUnexpandedParameterPacks(D))) + D.setEllipsisLoc(ConsumeToken()); + if (Tok.is(tok::identifier) || Tok.is(tok::kw_operator) || Tok.is(tok::annot_template_id) || Tok.is(tok::tilde)) { // We found something that indicates the start of an unqualified-id. |