re PR c++/56915 (ICE in symtab_add_to_same_comdat_group, at symtab.c:383)
authorJason Merrill <jason@redhat.com>
Thu, 23 May 2013 03:46:44 +0000 (23:46 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 May 2013 03:46:44 +0000 (23:46 -0400)
PR c++/56915
* semantics.c (maybe_add_lambda_conv_op): Give up if the call op
isn't defined.

From-SVN: r199231

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C [new file with mode: 0644]

index f665312bdeb9539e4aacecc2213ef856eb517c8f..cd58d70f4a010018698b66db3b720417394f5b5d 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56915
+       * semantics.c (maybe_add_lambda_conv_op): Give up if the call op
+       isn't defined.
+
 2013-05-22  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/57352
index 92a4917fb404837c79d9037ff2dea18bd3835a97..5b363377b53045fcfa3066f64886179c10599a92 100644 (file)
@@ -9784,6 +9784,13 @@ maybe_add_lambda_conv_op (tree type)
   if (processing_template_decl)
     return;
 
+  if (DECL_INITIAL (callop) == NULL_TREE)
+    {
+      /* If the op() wasn't instantiated due to errors, give up.  */
+      gcc_assert (errorcount || sorrycount);
+      return;
+    }
+
   stattype = build_function_type (TREE_TYPE (TREE_TYPE (callop)),
                                  FUNCTION_ARG_CHAIN (callop));
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C
new file mode 100644 (file)
index 0000000..520b804
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/56915
+// { dg-require-effective-target c++11 }
+
+template <typename T>
+class A
+{
+    typename T::type b();      // { dg-error "int" }
+};
+
+template <typename T, typename U>
+void waldo(T, U) {}
+
+template <typename T>
+void bar()
+{
+    waldo([](A<T> a){ return a; },
+          []{});
+}
+
+int main()
+{
+    bar<int>();
+}
+
+// { dg-prune-output "used but never defined" }