From 2701664a0266af935d5fea7c5586a5686fe32365 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 22 May 2013 23:46:44 -0400 Subject: [PATCH] re PR c++/56915 (ICE in symtab_add_to_same_comdat_group, at symtab.c:383) 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 | 6 +++++ gcc/cp/semantics.c | 7 ++++++ .../g++.dg/cpp0x/lambda/lambda-template11.C | 25 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f665312bdeb..cd58d70f4a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-22 Jason Merrill + + PR c++/56915 + * semantics.c (maybe_add_lambda_conv_op): Give up if the call op + isn't defined. + 2013-05-22 Paolo Carlini PR c++/57352 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 92a4917fb40..5b363377b53 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 index 00000000000..520b80488a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C @@ -0,0 +1,25 @@ +// PR c++/56915 +// { dg-require-effective-target c++11 } + +template +class A +{ + typename T::type b(); // { dg-error "int" } +}; + +template +void waldo(T, U) {} + +template +void bar() +{ + waldo([](A a){ return a; }, + []{}); +} + +int main() +{ + bar(); +} + +// { dg-prune-output "used but never defined" } -- 2.30.2