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++/61566 (ICE with lambda in template default arg)
Date: Mon, 30 Jun 2014 18:50:00 -0000	[thread overview]
Message-ID: <53B1B157.1090906@redhat.com> (raw)

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

decl_mangling_context was failing to recognize a lambda in template 
context as a lambda.

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

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

commit 1ba7cf95c0b024c7a3372e0734d7bf620f31dd14
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 30 12:08:09 2014 -0400

    	PR c++/61566
    	* mangle.c (decl_mangling_context): Look through a TEMPLATE_DECL.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index ac1c1da..02c05d4 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -742,6 +742,10 @@ decl_mangling_context (tree decl)
   if (tcontext != NULL_TREE)
     return tcontext;
 
+  if (TREE_CODE (decl) == TEMPLATE_DECL
+      && DECL_TEMPLATE_RESULT (decl))
+    decl = DECL_TEMPLATE_RESULT (decl);
+
   if (TREE_CODE (decl) == TYPE_DECL
       && LAMBDA_TYPE_P (TREE_TYPE (decl)))
     {
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C
new file mode 100644
index 0000000..adbb4db
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C
@@ -0,0 +1,20 @@
+// PR c++/61566
+// { dg-do compile { target c++11 } }
+
+struct function
+{
+  template < typename _Functor>
+  function (_Functor);
+};
+
+struct C
+{
+  template <typename T>
+  void foo (T, function = [] {});
+};
+
+void bar ()
+{
+  C c;
+  c.foo (1);
+}

             reply	other threads:[~2014-06-30 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30 18:50 Jason Merrill [this message]
2014-08-15 22:27 ` Jason Merrill

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=53B1B157.1090906@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).