public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration")
@ 2015-09-09 16:58 Paolo Carlini
  2015-09-09 18:51 ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2015-09-09 16:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi,

I tracked down this regression to r225621, a clean up committed by Jason 
a while ago: unless we want to try something more aggressive, we can fix 
it the regression by simply restoring a few lines in 
cp_parser_template_parameter which consume the ellipsis. To clarify 
implementation-wise, the types affected are essentially all those for 
which cp_parser_simple_type_specifier (thus 
cp_parser_parameter_declaration) doesn't set the type in decl_specs:

       if (decl_specs
       && (token->keyword != RID_SIGNED
           && token->keyword != RID_UNSIGNED
           && token->keyword != RID_SHORT
           && token->keyword != RID_LONG))
     cp_parser_set_decl_spec_type (decl_specs,
                       type,
                       token,
                       /*type_definition_p=*/false);

Weird that we didn't have any testcase!

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////




[-- Attachment #2: CL_67318 --]
[-- Type: text/plain, Size: 323 bytes --]

/cp
2015-09-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67318
	* parser.c (cp_parser_template_parameter): Revert a few lines of
	r225621: consume the ellipsis and set *is_parameter_pack to true.

/testsuite
2015-09-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67318
	* g++.dg/cpp0x/variadic166.C: New.

[-- Attachment #3: patch_67318 --]
[-- Type: text/plain, Size: 1425 bytes --]

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 227586)
+++ cp/parser.c	(working copy)
@@ -13811,6 +13811,20 @@ cp_parser_template_parameter (cp_parser* parser, b
 	/* Consume the `...' for better error recovery.  */
 	cp_lexer_consume_token (parser->lexer);
     }
+  /* If the next token is an ellipsis, and we don't already have it
+     marked as a parameter pack, then we have a parameter pack (that
+     has no declarator).  */
+  else if (!*is_parameter_pack
+	   && cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)
+	   && (declarator_can_be_parameter_pack
+	       (parameter_declarator->declarator)))
+    {
+      /* Consume the `...'.  */
+      cp_lexer_consume_token (parser->lexer);
+      maybe_warn_variadic_templates ();
+      
+      *is_parameter_pack = true;
+    }
 
   // The parameter may have been constrained.
   if (is_constrained_parameter (parameter_declarator))
Index: testsuite/g++.dg/cpp0x/variadic166.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic166.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/variadic166.C	(working copy)
@@ -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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration")
  2015-09-09 16:58 [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration") Paolo Carlini
@ 2015-09-09 18:51 ` Jason Merrill
  2015-09-09 19:35   ` Paolo Carlini
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2015-09-09 18:51 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

We should fix the logic in cp_parser_parameter_declaration to handle 
this, not work around it here.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration")
  2015-09-09 18:51 ` Jason Merrill
@ 2015-09-09 19:35   ` Paolo Carlini
  2015-09-09 21:14     ` Paolo Carlini
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2015-09-09 19:35 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches

Hi,

On 09/09/2015 08:42 PM, Jason Merrill wrote:
> We should fix the logic in cp_parser_parameter_declaration to handle 
> this, not work around it here.
Ok, that's what I meant for "more aggressive" ;) I didn't try do that 
immediately when I noticed that the function is called from a few other 
places, but I'll do that now. If I can't sort it out as quickly as I 
want I'll tell you, the issue seems rather annoying...

Thanks!
Paolo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration")
  2015-09-09 19:35   ` Paolo Carlini
@ 2015-09-09 21:14     ` Paolo Carlini
  2015-09-10 13:36       ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2015-09-09 21:14 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

... what about something this simple? Passes testing...

Thanks,
Paolo.

///////////////////////////

[-- Attachment #2: patch_67318_2 --]
[-- Type: text/plain, Size: 1283 bytes --]

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 227600)
+++ cp/parser.c	(working copy)
@@ -19626,11 +19626,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 ();
Index: testsuite/g++.dg/cpp0x/variadic166.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic166.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/variadic166.C	(working copy)
@@ -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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration")
  2015-09-09 21:14     ` Paolo Carlini
@ 2015-09-10 13:36       ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2015-09-10 13:36 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-10 13:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09 16:58 [C++ Patch] PR 67318 ("[6 regression] Parsing error when using abbreviated integral type names in template parameter pack declaration") Paolo Carlini
2015-09-09 18:51 ` Jason Merrill
2015-09-09 19:35   ` Paolo Carlini
2015-09-09 21:14     ` Paolo Carlini
2015-09-10 13:36       ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).