From f395f5e2a1c7d512fc268d447f58b3ec83ae9506 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 5 Jul 2011 10:47:21 -0400 Subject: [PATCH] re PR c++/49598 ([C++0x] Ice on lambda with implicit capture by value.) PR c++/49598 * semantics.c (finish_id_expression): convert_from_reference. From-SVN: r175857 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/semantics.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C | 13 +++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d3aa1a9dd84..a1104b44de9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-07-05 Jason Merrill + + PR c++/49598 + * semantics.c (finish_id_expression): convert_from_reference. + 2011-07-05 Richard Guenther * decl.c (cxx_init_decl_processing): Defer building common diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 619c0580e84..fa22bc9411f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2942,7 +2942,7 @@ finish_id_expression (tree id_expression, tree containing_function = current_function_decl; tree lambda_stack = NULL_TREE; tree lambda_expr = NULL_TREE; - tree initializer = decl; + tree initializer = convert_from_reference (decl); /* Core issue 696: "[At the July 2009 meeting] the CWG expressed support for an approach in which a reference to a local diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 87833d3fdfa..891763504d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-07-05 Jason Merrill + + * g++.dg/cpp0x/lambda/lambda-ref2.C: New. + 2011-07-05 Razya Ladelsky PR tree-optimization/49580 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C new file mode 100644 index 00000000000..15f1d9034a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C @@ -0,0 +1,13 @@ +// PR c++/49598 +// { dg-options -std=c++0x } +// { dg-do run } + +int +main() +{ + int i = 10; + int& ir = i; + + if ([=]{ return ir; }() != 10) + return 1; +} -- 2.30.2