public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/55232 (ICE on diagnostic in variadic template function)
Date: Thu, 14 Feb 2013 19:54:00 -0000	[thread overview]
Message-ID: <511D40CC.4020304@redhat.com> (raw)

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

We try to print typename types when dumping template bindings in order 
to be helpful.  But we can't do that for typenames in pack expansions 
because we don't know which pack element we're interested in.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 55232.patch --]
[-- Type: text/x-patch, Size: 1711 bytes --]

commit 91f6181cddda74ddfbae6e57454ab69659847928
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 14 09:13:54 2013 -0500

    	PR c++/55232
    	* error.c (find_typenames_r): Don't walk into a pack expansion.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index a4b3320..60119ec 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1283,7 +1283,7 @@ struct find_typenames_t
 };
 
 static tree
-find_typenames_r (tree *tp, int * /*walk_subtrees*/, void *data)
+find_typenames_r (tree *tp, int *walk_subtrees, void *data)
 {
   struct find_typenames_t *d = (struct find_typenames_t *)data;
   tree mv = NULL_TREE;
@@ -1296,6 +1296,14 @@ find_typenames_r (tree *tp, int * /*walk_subtrees*/, void *data)
     /* Add the typename without any cv-qualifiers.  */
     mv = TYPE_MAIN_VARIANT (*tp);
 
+  if (TREE_CODE (*tp) == TYPE_PACK_EXPANSION)
+    {
+      /* Don't mess with parameter packs since we don't remember
+	 the pack expansion context for a particular typename.  */
+      *walk_subtrees = false;
+      return NULL_TREE;
+    }
+
   if (mv && (mv == *tp || !pointer_set_insert (d->p_set, mv)))
     vec_safe_push (d->typenames, mv);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-diag1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-diag1.C
new file mode 100644
index 0000000..53182d3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-diag1.C
@@ -0,0 +1,22 @@
+// PR c++/55232
+// { dg-do compile { target c++11 } }
+
+struct vector
+{
+    typedef int value_type;
+};
+
+template< class U, class... T >
+struct X
+{
+    void push_back( typename T::value_type ... vals )
+    {
+      U::asoeuth;		// { dg-error "" }
+    }
+};
+
+int main()
+{
+  X< int, vector > x;
+  x.push_back( 0 );
+}

                 reply	other threads:[~2013-02-14 19:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=511D40CC.4020304@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).