public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
@ 2007-11-18 15:46 Doug Gregor
  2007-11-18 21:51 ` Jakub Jelinek
  2007-12-03 21:39 ` Jason Merrill
  0 siblings, 2 replies; 4+ messages in thread
From: Doug Gregor @ 2007-11-18 15:46 UTC (permalink / raw)
  To: GCC Patches

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

This little patch fixes PR 33509, a P2 ice-on-valid where we failed to
handle the instantiation of exception specifications that involve
parameter packs from multiple levels of template parameters. The fix
is relatively simple; we just deal with the resulting
TYPE_PACK_EXPANSION explicitly.

Tested i686-pc-linux-gnu; okay for mainline?

  - Doug

2007-11-18  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/33509
	* pt.c (tsubst_exception_specification): Handle substitutions into
	member templates, where tsubst_pack_expansion returns a
	TYPE_PACK_EXPANSION.

2007-11-18  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/33509
	* g++.dg/cpp0x/variadic-throw.C: New.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: variadic-throw.patch --]
[-- Type: text/x-patch; name=variadic-throw.patch, Size: 1662 bytes --]

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 130268)
+++ cp/pt.c	(working copy)
@@ -8653,7 +8653,24 @@ tsubst_exception_specification (tree fnt
                 expanded_specs = tsubst_pack_expansion (TREE_VALUE (specs),
                                                        args, complain,
                                                        in_decl);
-                len = TREE_VEC_LENGTH (expanded_specs);
+
+		if (expanded_specs == error_mark_node)
+		  return error_mark_node;
+		else if (TREE_CODE (expanded_specs) == TREE_VEC)
+		  len = TREE_VEC_LENGTH (expanded_specs);
+		else
+		  {
+		    /* We're substituting into a member template, so
+		       we got a TYPE_PACK_EXPANSION back.  Add that
+		       expansion and move on.  */
+		    gcc_assert (TREE_CODE (expanded_specs) 
+				== TYPE_PACK_EXPANSION);
+		    new_specs = add_exception_specifier (new_specs,
+							 expanded_specs,
+							 complain);
+		    specs = TREE_CHAIN (specs);
+		    continue;
+		  }
               }
 
             for (i = 0; i < len; ++i)
Index: testsuite/g++.dg/cpp0x/variadic-throw.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic-throw.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/variadic-throw.C	(revision 0)
@@ -0,0 +1,20 @@
+// { dg-options -std=c++0x }
+// PR c++/33509
+template<int M, int N> struct pair
+{
+  int i, j;
+  pair() : i(M), j(N) {}
+};
+
+template<int... M> struct S
+{
+  template<int... N> static int foo() throw (pair <M, N>...)
+  {
+    return 1;
+  }
+};
+
+int bar ()
+{
+  return S<0, 1, 2>::foo<0, 1, 3> ();
+}

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

* Re: [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
  2007-11-18 15:46 [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification Doug Gregor
@ 2007-11-18 21:51 ` Jakub Jelinek
  2007-11-19 16:43   ` Doug Gregor
  2007-12-03 21:39 ` Jason Merrill
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2007-11-18 21:51 UTC (permalink / raw)
  To: Doug Gregor; +Cc: GCC Patches

On Sun, Nov 18, 2007 at 09:38:27AM -0500, Doug Gregor wrote:
> This little patch fixes PR 33509, a P2 ice-on-valid where we failed to
> handle the instantiation of exception specifications that involve
> parameter packs from multiple levels of template parameters. The fix
> is relatively simple; we just deal with the resulting
> TYPE_PACK_EXPANSION explicitly.
> 
> Tested i686-pc-linux-gnu; okay for mainline?
> 
> 2007-11-18  Douglas Gregor  <doug.gregor@gmail.com>
> 
> 	PR c++/33509
> 	* pt.c (tsubst_exception_specification): Handle substitutions into
> 	member templates, where tsubst_pack_expansion returns a
> 	TYPE_PACK_EXPANSION.
> 
> 2007-11-18  Douglas Gregor  <doug.gregor@gmail.com>
> 
> 	PR c++/33509
> 	* g++.dg/cpp0x/variadic-throw.C: New.

I think it would be good to add not only this valid testcase, but
the invalid one as well (i.e. one with
return S<0, 1, 2>::foo<0, 1> ();
rather than
return S<0, 1, 2>::foo<0, 1, 3> ();
) to make sure it doesn't ICE and issues some meaningful error
on invalid code.

	Jakub

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

* Re: [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
  2007-11-18 21:51 ` Jakub Jelinek
@ 2007-11-19 16:43   ` Doug Gregor
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Gregor @ 2007-11-19 16:43 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches

On Nov 18, 2007 3:01 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > 2007-11-18  Douglas Gregor  <doug.gregor@gmail.com>
> >
> >       PR c++/33509
> >       * g++.dg/cpp0x/variadic-throw.C: New.
>
> I think it would be good to add not only this valid testcase, but
> the invalid one as well (i.e. one with
> return S<0, 1, 2>::foo<0, 1> ();
> rather than
> return S<0, 1, 2>::foo<0, 1, 3> ();
> ) to make sure it doesn't ICE and issues some meaningful error
> on invalid code.

Okay, will do.

  - Doug

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

* Re: [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
  2007-11-18 15:46 [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification Doug Gregor
  2007-11-18 21:51 ` Jakub Jelinek
@ 2007-12-03 21:39 ` Jason Merrill
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2007-12-03 21:39 UTC (permalink / raw)
  To: Doug Gregor; +Cc: GCC Patches

OK.

Jason

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

end of thread, other threads:[~2007-12-03 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-18 15:46 [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification Doug Gregor
2007-11-18 21:51 ` Jakub Jelinek
2007-11-19 16:43   ` Doug Gregor
2007-12-03 21:39 ` 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).