From a728a2ada0698cbd8688d5eb6d88d357ec27eb5b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 30 Aug 2011 11:28:40 -0400 Subject: [PATCH] re PR c++/50220 ([C++0x] [4.7 Regression] ICE when capturing a by-reference template function argument in a lambda) PR c++/50220 * semantics.c (add_capture): Call complete_type for copy. From-SVN: r178326 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 3 +++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C | 9 +++++++++ 4 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9abac29a151..c2c00a7adf9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-08-30 Jason Merrill + PR c++/50220 + * semantics.c (add_capture): Call complete_type for copy. + PR c++/50234 * semantics.c (cxx_eval_component_reference): Handle value-initialization for omitted initializers. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1ad991fab4e..dd7c01373b5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8651,6 +8651,9 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, if (!real_lvalue_p (initializer)) error ("cannot capture %qE by reference", initializer); } + else + /* Capture by copy requires a complete type. */ + type = complete_type (type); /* Add __ to the beginning of the field name so that user code won't find the field with name lookup. We can't just leave the name diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 237deac888c..ccaf17c06b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-30 Jason Merrill + PR c++/50220 + * g++.dg/cpp0x/lambda/lambda-50220.C: New. + PR c++/50234 * g++.dg/cpp0x/constexpr-value3.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C new file mode 100644 index 00000000000..240143cf65c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C @@ -0,0 +1,9 @@ +// PR c++/50220 +// { dg-options -std=c++0x } + +template struct Foobar {}; + +void foobar(const Foobar& obj) +{ + [obj](){}(); +}