@@ -67,7 +67,8 @@ lvalue_kind (const_tree ref)
== REFERENCE_TYPE)
return lvalue_kind (TREE_OPERAND (ref, 0));
- if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
+ if (TREE_TYPE (ref)
+ && TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
{
/* unnamed rvalue references are rvalues */
if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
@@ -0,0 +1,28 @@
+// PR c++/45894
+// { dg-do compile }
+// { dg-options "-std=c++0x -Wsequence-point" }
+
+struct F
+{
+ template <typename = int>
+ void bar ();
+};
+template <typename = int>
+struct V
+{
+ V (const V &) { F::bar <>; }
+};
+struct C
+{
+ V <> v;
+};
+struct B
+{
+ C f ();
+};
+struct A
+{
+ C c;
+ B b;
+ A () : c (b.f ()) { }
+};