2010-06-07 Jakub Jelinek <jakub@redhat.com>
+ PR c++/44444
+ * expr.c (mark_exp_read): Handle INDIRECT_REF.
+ * cvt.c (convert_to_void): Handle INDIRECT_REF like
+ handled_component_p.
+
PR c++/44443
* decl.c (initialize_local_var): If TREE_USED is set on the type,
set also DECL_READ_P on the decl.
while (TREE_CODE (exprv) == COMPOUND_EXPR)
exprv = TREE_OPERAND (exprv, 1);
- if (DECL_P (exprv) || handled_component_p (exprv))
+ if (DECL_P (exprv)
+ || handled_component_p (exprv)
+ || TREE_CODE (exprv) == INDIRECT_REF)
/* Expr is not being 'used' here, otherwise we whould have
called mark_{rl}value_use use here, which would have in turn
called mark_exp_read. Rather, we call mark_exp_read directly
/* Convert language-specific tree expression to rtl instructions,
for GNU compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 2000, 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ 2000, 2001, 2002, 2003, 2004, 2007, 2010 Free Software Foundation, Inc.
This file is part of GCC.
case IMAGPART_EXPR:
CASE_CONVERT:
case ADDR_EXPR:
+ case INDIRECT_REF:
mark_exp_read (TREE_OPERAND (exp, 0));
break;
case COMPOUND_EXPR:
2010-06-07 Jakub Jelinek <jakub@redhat.com>
+ PR c++/44444
+ * g++.dg/warn/Wunused-var-12.C: New test.
+
PR c++/44443
* c-c++-common/Wunused-var-11.c: New test.
--- /dev/null
+// PR c++/44444
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+struct S
+{
+ const int &u;
+ const int &v;
+ S (const int &a, const int &b) : u(a), v(b) { }
+};
+
+bool
+f1 ()
+{
+ bool t = false;
+ S z = S (1, 2);
+ t |= z.u == 1;
+ t |= z.v == 2;
+ return t;
+}
+
+void
+f2 ()
+{
+ S z = S (1, 2);
+ z.u; // { dg-warning "no effect" }
+}
+
+int i;
+
+void
+f3 ()
+{
+ S z = S (1, 2);
+ i++, z.u; // { dg-warning "no effect" }
+}