diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 11 | ||||
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 13 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 9d8aed5333..9aa5eaba00 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3354,15 +3354,17 @@ bool Parser::isConstructorDeclarator() { return false; } - // Current class name must be followed by a left parentheses. + // Current class name must be followed by a left parenthesis. if (Tok.isNot(tok::l_paren)) { TPA.Revert(); return false; } ConsumeParen(); - // A right parentheses or ellipsis signals that we have a constructor. - if (Tok.is(tok::r_paren) || Tok.is(tok::ellipsis)) { + // A right parenthesis, or ellipsis followed by a right parenthesis signals + // that we have a constructor. + if (Tok.is(tok::r_paren) || + (Tok.is(tok::ellipsis) && NextToken().is(tok::r_paren))) { TPA.Revert(); return true; } @@ -3948,7 +3950,8 @@ void Parser::ParseParenDeclarator(Declarator &D) { // paren, because we haven't seen the identifier yet. isGrouping = true; } else if (Tok.is(tok::r_paren) || // 'int()' is a function. - (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis)) || // C++ int(...) + (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) && + NextToken().is(tok::r_paren)) || // C++ int(...) isDeclarationSpecifier()) { // 'int(int)' is a function. // This handles C99 6.7.5.3p11: in "typedef int X; void foo(X)", X is // considered to be a type, not a K&R identifier-list. diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 1e30c7fff6..e3b922500f 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -553,7 +553,8 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, ConsumeParen(); if (mayBeAbstract && (Tok.is(tok::r_paren) || // 'int()' is a function. - Tok.is(tok::ellipsis) || // 'int(...)' is a function. + // 'int(...)' is a function. + (Tok.is(tok::ellipsis) && NextToken().is(tok::r_paren)) || isDeclarationSpecifier())) { // 'int(int)' is a function. // '(' parameter-declaration-clause ')' cv-qualifier-seq[opt] // exception-specification[opt] @@ -1236,7 +1237,10 @@ Parser::TPResult Parser::TryParseParameterDeclarationClause() { // '...'[opt] if (Tok.is(tok::ellipsis)) { ConsumeToken(); - return TPResult::True(); // '...' is a sign of a function declarator. + if (Tok.is(tok::r_paren)) + return TPResult::True(); // '...)' is a sign of a function declarator. + else + return TPResult::False(); } ParsedAttributes attrs(AttrFactory); @@ -1269,7 +1273,10 @@ Parser::TPResult Parser::TryParseParameterDeclarationClause() { if (Tok.is(tok::ellipsis)) { ConsumeToken(); - return TPResult::True(); // '...' is a sign of a function declarator. + if (Tok.is(tok::r_paren)) + return TPResult::True(); // '...)' is a sign of a function declarator. + else + return TPResult::False(); } if (Tok.isNot(tok::comma)) |