diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2015-09-10 15:36:54 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-09-10 15:36:54 +0000 |
commit | 08f8b6653ad6351e58dd466ca8be575e2855b88a (patch) | |
tree | d6b0747256243a640b4bfb7b870d293c49062ada /gcc | |
parent | dbb68221b64c0174eeb22d878a8e078775ee73bf (diff) | |
download | gcc-08f8b6653ad6351e58dd466ca8be575e2855b88a.zip gcc-08f8b6653ad6351e58dd466ca8be575e2855b88a.tar.gz gcc-08f8b6653ad6351e58dd466ca8be575e2855b88a.tar.bz2 |
re PR c++/67318 (Parsing error when using abbreviated integral type names in template parameter pack declaration)
/cp
2015-09-10 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
PR c++/67318
* g++.dg/cpp0x/variadic166.C: New.
From-SVN: r227650
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic166.C | 14 |
4 files changed, 37 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3392773..a9952fc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-09-10 Paolo Carlini <paolo.carlini@oracle.com> + + 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 <mjw@redhat.com> * 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 d96825b..64eb5ea 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 f99682c..34ad007 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/67318 + * g++.dg/cpp0x/variadic166.C: New. + 2015-09-09 Mark Wielaard <mjw@redhat.com> * 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 0000000..91455cb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic166.C @@ -0,0 +1,14 @@ +// PR c++/67318 +// { dg-do compile { target c++11 } } + +template<signed...> +struct MyStruct1; + +template<unsigned...> +struct MyStruct2; + +template<short...> +struct MyStruct3; + +template<long...> +struct MyStruct4; |