From: Paolo Carlini Date: Thu, 10 Sep 2015 15:36:54 +0000 (+0000) Subject: re PR c++/67318 (Parsing error when using abbreviated integral type names in template... X-Git-Tag: basepoints/gcc-7~4652 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08f8b6653ad6351e58dd466ca8be575e2855b88a;p=thirdparty%2Fgcc.git re PR c++/67318 (Parsing error when using abbreviated integral type names in template parameter pack declaration) /cp 2015-09-10 Paolo Carlini PR c++/67318 * parser.c (cp_parser_parameter_declaration): Consume the ellipsis and set template_parameter_pack_p also when the type is null. /testsuite 2015-09-10 Paolo Carlini PR c++/67318 * g++.dg/cpp0x/variadic166.C: New. From-SVN: r227650 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 339277339b7b..a9952fcae755 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-09-10 Paolo Carlini + + PR c++/67318 + * parser.c (cp_parser_parameter_declaration): Consume the ellipsis + and set template_parameter_pack_p also when the type is null. + 2015-09-09 Mark Wielaard * typeck.c (cp_build_binary_op): Check and warn when nonnull arg diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d96825b08af0..64eb5ea88038 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19613,11 +19613,12 @@ cp_parser_parameter_declaration (cp_parser *parser, } } - /* If the next token is an ellipsis, and we have not seen a - declarator name, and the type of the declarator contains parameter - packs but it is not a TYPE_PACK_EXPANSION, then we actually have - a parameter pack expansion expression. Otherwise, leave the - ellipsis for a C-style variadic function. */ + /* If the next token is an ellipsis, and we have not seen a declarator + name, and if either the type of the declarator contains parameter + packs but it is not a TYPE_PACK_EXPANSION or is null (this happens + for, eg, abbreviated integral type names), then we actually have a + parameter pack expansion expression. Otherwise, leave the ellipsis + for a C-style variadic function. */ token = cp_lexer_peek_token (parser->lexer); if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) { @@ -19626,11 +19627,12 @@ cp_parser_parameter_declaration (cp_parser *parser, if (type && DECL_P (type)) type = TREE_TYPE (type); - if (type - && TREE_CODE (type) != TYPE_PACK_EXPANSION - && declarator_can_be_parameter_pack (declarator) - && (template_parm_p || uses_parameter_packs (type))) - { + if (((type + && TREE_CODE (type) != TYPE_PACK_EXPANSION + && (template_parm_p || uses_parameter_packs (type))) + || (!type && template_parm_p)) + && declarator_can_be_parameter_pack (declarator)) + { /* Consume the `...'. */ cp_lexer_consume_token (parser->lexer); maybe_warn_variadic_templates (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f99682cf352a..34ad00712ff6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-10 Paolo Carlini + + PR c++/67318 + * g++.dg/cpp0x/variadic166.C: New. + 2015-09-09 Mark Wielaard * c-c++-common/nonnull-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic166.C b/gcc/testsuite/g++.dg/cpp0x/variadic166.C new file mode 100644 index 000000000000..91455cbf0375 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic166.C @@ -0,0 +1,14 @@ +// PR c++/67318 +// { dg-do compile { target c++11 } } + +template +struct MyStruct1; + +template +struct MyStruct2; + +template +struct MyStruct3; + +template +struct MyStruct4;