This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix ICE in lvalue_kind (PR c++/45894)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 8 Nov 2010 23:12:17 +0100
- Subject: [C++ PATCH] Fix ICE in lvalue_kind (PR c++/45894)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
As the testcase shows, in some cases -Wsequence-point warning code
calls lvalue_p e.g. on baselink with template_id_expr (where the
latter has no type and thus lvalue_kind segfaults).
Fixed by robustifying lvalue_kind, bootstrapped/regtested on x86_64-linux
and i686-linux, ok for trunk?
2010-11-05 Jakub Jelinek <jakub@redhat.com>
PR c++/45894
* tree.c (lvalue_kind): Don't crash if ref has NULL type.
* g++.dg/warn/Wsequence-point-2.C: New test.
--- gcc/cp/tree.c.jj 2010-11-03 16:58:26.000000000 +0100
+++ gcc/cp/tree.c 2010-11-05 13:45:53.000000000 +0100
@@ -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))
--- gcc/testsuite/g++.dg/warn/Wsequence-point-2.C.jj 2010-11-08 18:09:07.000000000 +0100
+++ gcc/testsuite/g++.dg/warn/Wsequence-point-2.C 2010-11-08 18:08:04.000000000 +0100
@@ -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 ()) { }
+};
Jakub