Hi,
On 10/06/2012 03:52 PM, Jason Merrill wrote:
On 09/27/2012 07:08 AM, Paolo Carlini wrote:
Then checking error_operand_p (decl) in is_capture_proxy solves the
problem but now the question is: do we have reasons to believe that such
VAR_DECLs should never ever reach is_normal_capture_proxy?
That depends on our error recovery strategy for an invalid capture.
It seems that we currently build a VAR_DECL that has an
error_mark_node DECL_VALUE_EXPR; if we're going to do that, we need to
deal with it. I guess we should return true in that case, if it
doesn't cause more problems later on.
Ah good, thanks for the suggestion. Then the below passes testing on
x86_64-linux. Ok for mainline?
Thanks again,
Paolo.
////////////////////////
/cp
2012-10-07 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51422
* semantics.c (is_normal_capture_proxy): Return true for
error_mark_node as DECL_VALUE_EXPR.
/testsuite
2012-10-07 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51422
* g++.dg/cpp0x/lambda/lambda-ice8.C: New.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 192179)
+++ cp/semantics.c (working copy)
@@ -3,8 +3,7 @@
building RTL. These routines are used both during actual parsing
and during the instantiation of template functions.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 1998-2012 Free Software Foundation, Inc.
Written by Mark Mitchell (mmitch...@usa.net) based on code found
formerly in parse.y and pt.c.
@@ -9005,14 +9004,15 @@ is_capture_proxy (tree decl)
bool
is_normal_capture_proxy (tree decl)
{
- tree val;
-
if (!is_capture_proxy (decl))
/* It's not a capture proxy. */
return false;
/* It is a capture proxy, is it a normal capture? */
- val = DECL_VALUE_EXPR (decl);
+ tree val = DECL_VALUE_EXPR (decl);
+ if (val == error_mark_node)
+ return true;
+
gcc_assert (TREE_CODE (val) == COMPONENT_REF);
val = TREE_OPERAND (val, 1);
return DECL_NORMAL_CAPTURE_P (val);
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C (revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/51422
+// { dg-do compile { target c++11 } }
+
+template<typename> struct A {};
+
+void foo()
+{
+ [i] { A<decltype(i)>(); }; // { dg-error "not declared|invalid" }
+ [i] { A<decltype(i)>(); }; // { dg-error "invalid" }
+}