re PR c++/49598 ([C++0x] Ice on lambda with implicit capture by value.)
authorJason Merrill <jason@redhat.com>
Tue, 5 Jul 2011 14:47:21 +0000 (10:47 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 5 Jul 2011 14:47:21 +0000 (10:47 -0400)
PR c++/49598
* semantics.c (finish_id_expression): convert_from_reference.

From-SVN: r175857

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

index d3aa1a9dd844f241a6f742c5c9c47d21062bfcc9..a1104b44de9fff363a19cfbda304fae12c2af5e2 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-05  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49598
+       * semantics.c (finish_id_expression): convert_from_reference.
+
 2011-07-05  Richard Guenther  <rguenther@suse.de>
 
        * decl.c (cxx_init_decl_processing): Defer building common
index 619c0580e841c55f214b1aeb87afb5311d2b2f9c..fa22bc9411fc6e0c83b97056be4f96f67fd24583 100644 (file)
@@ -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
index 87833d3fdfa60d45a016d0a79c10f897552fe962..891763504d3b9af48826bc7cce7f6590278f068c 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/lambda/lambda-ref2.C: New.
+
 2011-07-05  Razya Ladelsky  <razya@il.ibm.com>
 
        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 (file)
index 0000000..15f1d90
--- /dev/null
@@ -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;
+}