From: Faisal Vali Date: Thu, 4 Dec 2014 12:40:21 +0000 (+0000) Subject: Fix PR21684 - Ellipsis following an 'auto' parameter sans name/ID X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61f9a779a8508a7aeed14a60a8028cd1c64b264e;p=clang Fix PR21684 - Ellipsis following an 'auto' parameter sans name/ID should indicate a c++ parameter pack not a c-variadic. int i = [](auto...) { return 0; }(); // OK now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223357 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 5af7b69999..fc6c7cebe2 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4873,19 +4873,20 @@ void Parser::ParseDirectDeclarator(Declarator &D) { } // 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. + // 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 either names a template parameter pack that has not + // been expanded or contains auto; otherwise, it is parsed as part of the + // parameter-declaration-clause. if (Tok.is(tok::ellipsis) && D.getCXXScopeSpec().isEmpty() && !((D.getContext() == Declarator::PrototypeContext || D.getContext() == Declarator::LambdaExprParameterContext || D.getContext() == Declarator::BlockLiteralContext) && NextToken().is(tok::r_paren) && !D.hasGroupingParens() && - !Actions.containsUnexpandedParameterPacks(D))) { + !Actions.containsUnexpandedParameterPacks(D) && + D.getDeclSpec().getTypeSpecType() != TST_auto)) { SourceLocation EllipsisLoc = ConsumeToken(); if (isPtrOperatorToken(Tok.getKind(), getLangOpts(), D.getContext())) { // The ellipsis was put in the wrong place. Recover, and explain to diff --git a/test/SemaCXX/cxx1y-generic-lambdas.cpp b/test/SemaCXX/cxx1y-generic-lambdas.cpp index 8e07b806b1..395b580323 100644 --- a/test/SemaCXX/cxx1y-generic-lambdas.cpp +++ b/test/SemaCXX/cxx1y-generic-lambdas.cpp @@ -918,3 +918,7 @@ int run2 = x2.fooG3(); } //end ns inclass_lambdas_within_nested_classes + +namespace pr21684_disambiguate_auto_followed_by_ellipsis_no_id { +int a = [](auto ...) { return 0; }(); +} \ No newline at end of file