+2014-02-19 Marek Polacek <polacek@redhat.com>
+
+ PR c/60195
+ * c-typeck.c (convert_lvalue_to_rvalue): Set TREE_NO_WARNING on tmp.
+ Call mark_exp_read on exp.value.
+ (build_atomic_assign): Set TREE_NO_WARNING on val and old. Set
+ TREE_ADDRESSABLE on old instead of val.
+ (emit_side_effect_warnings): Warn only if RHS has !TREE_NO_WARNING.
+
2014-02-07 Prathamesh Kulkarni <bilbotheelffriend@gmail.com>
* c-parser.c (c_parser_get_builtin_args): Replace calls to
tmp = create_tmp_var (nonatomic_type, NULL);
tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, 0);
TREE_ADDRESSABLE (tmp) = 1;
+ TREE_NO_WARNING (tmp) = 1;
/* Issue __atomic_load (&expr, &tmp, SEQ_CST); */
fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
params->quick_push (seq_cst);
func_call = build_function_call_vec (loc, vNULL, fndecl, params, NULL);
+ /* EXPR is always read. */
+ mark_exp_read (exp.value);
+
/* Return tmp which contains the value loaded. */
exp.value = build2 (COMPOUND_EXPR, nonatomic_type, func_call, tmp);
}
nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
val = create_tmp_var (nonatomic_rhs_type, NULL);
TREE_ADDRESSABLE (val) = 1;
+ TREE_NO_WARNING (val) = 1;
rhs = build2 (MODIFY_EXPR, nonatomic_rhs_type, val, rhs);
SET_EXPR_LOCATION (rhs, loc);
add_stmt (rhs);
/* Create the variables and labels required for the op= form. */
old = create_tmp_var (nonatomic_lhs_type, NULL);
old_addr = build_unary_op (loc, ADDR_EXPR, old, 0);
- TREE_ADDRESSABLE (val) = 1;
+ TREE_ADDRESSABLE (old) = 1;
+ TREE_NO_WARNING (old) = 1;
newval = create_tmp_var (nonatomic_lhs_type, NULL);
newval_addr = build_unary_op (loc, ADDR_EXPR, newval, 0);
if (!TREE_SIDE_EFFECTS (r)
&& !VOID_TYPE_P (TREE_TYPE (r))
&& !CONVERT_EXPR_P (r)
+ && !TREE_NO_WARNING (r)
&& !TREE_NO_WARNING (expr))
warning_at (cloc, OPT_Wunused_value,
"right-hand operand of comma expression has no effect");