+2009-04-15 Le-Chun Wu <lcwu@google.com>
+
+ PR c++/39551
+ * call.c (build_over_call): Set TREE_NO_WARNING on the
+ compiler-generated INDIRECT_REF expression.
+ * cvt.c (convert_to_void): Emit warning when stripping off
+ INDIRECT_REF.
+
2009-04-14 Diego Novillo <dnovillo@google.com>
* parser.c (cp_parser_type_specifier_seq): Move call to
if (test)
t = build3 (COND_EXPR, TREE_TYPE (t), test, arg0, t);
val = cp_build_indirect_ref (t, 0, complain);
+ TREE_NO_WARNING (val) = 1;
}
return val;
implicit ? implicit : "void context");
}
if (is_reference || !is_volatile || !is_complete || TREE_ADDRESSABLE (type))
- expr = TREE_OPERAND (expr, 0);
+ {
+ /* Emit a warning (if enabled) when the "effect-less" INDIRECT_REF
+ operation is stripped off. Note that we don't warn about
+ - an expression with TREE_NO_WARNING set. (For an example of
+ such expressions, see build_over_call in call.c.)
+ - automatic dereferencing of references, since the user cannot
+ control it. (See also warn_if_unused_value() in stmt.c.) */
+ if (warn_unused_value
+ && (complain & tf_warning)
+ && !TREE_NO_WARNING (expr)
+ && !is_reference)
+ warning (OPT_Wunused_value, "value computed is not used");
+ expr = TREE_OPERAND (expr, 0);
+ }
break;
}
+2009-04-15 Le-Chun Wu <lcwu@google.com>
+
+ PR c++/39551
+ * g++.dg/warn/Wunused-13.C: New testcase.
+
2009-04-15 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wenum-compare-1.c: New testcase.
--- /dev/null
+// Test whether -Wunused handles effectless indirect_ref operation ('*').
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+void Foo(int* x) {
+ *x++; // { dg-warning "value computed is not used" }
+}