The problem here is that we end up with an INDIRECT_REF TREE_CODE with a
null TREE_TYPE in lvalue_kind. Is this possible at that point, or does
it point to a deeper underlying problem?

Bootstraped and tested on x86_64-pc-linux-gnu.

2012-10-27  Markus Trippelsdorf  <mar...@trippelsdorf.de>

        PR c++/50089
        PR c++/53921
        PR c++/55076
        * tree.c (lvalue_kind): Guard against null TREE_TYPE.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 8d555c2..0f1a75d 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -145,7 +145,7 @@ lvalue_kind (const_tree ref)
     case ARRAY_REF:
     case PARM_DECL:
     case RESULT_DECL:
-      if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
+      if (TREE_TYPE (ref) && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
        return clk_ordinary;
       break;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C 
b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C
new file mode 100644
index 0000000..76b6376
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C
@@ -0,0 +1,12 @@
+// PR c++/50089 c++/53921 c++/55076
+// { dg-do compile { target c++11 } }
+void a (int);
+template <bool>
+struct A
+{
+    int b;
+    void c ()
+    {
+        [=] { a (b); }; //ICE without this->b
+    };
+};
-- 
Markus

Reply via email to