From b43247d3e742cf5523a20a05c722cecb907e7295 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 23 May 2013 03:46:44 +0000 Subject: [PATCH] PR c++/56915 * semantics.c (maybe_add_lambda_conv_op): Give up if the call op isn't defined. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199231 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 f665312..cd58d70 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 92a4917..5b36337 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 0000000..520b804 --- /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.7.4