type = c_common_unsigned_type (type);
}
- if (TREE_CODE (primop0) != INTEGER_CST
- && c_inhibit_evaluation_warnings == 0)
+ if (TREE_CODE (primop0) != INTEGER_CST)
{
if (val == truthvalue_false_node)
warning_at (loc, OPT_Wtype_limits,
warning. */
bool warn =
warn_type_limits && !in_system_header_at (loc)
- && c_inhibit_evaluation_warnings == 0
&& !(TREE_CODE (primop0) == INTEGER_CST
&& !TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0)))
2014-02-26 Jason Merrill <jason@redhat.com>
+ PR c++/59231
+ PR c++/11586
+ PR c++/14710
+ PR c++/57132
+ * pt.c (struct warning_sentinel): New.
+ (tsubst_copy_and_build): Use it instead of
+ c_inhibit_evaluation_warnings.
+ * typeck.c (maybe_warn_about_useless_cast): Remove
+ c_inhibit_evaluation_warnings check.
+
PR c++/54440
* pt.c (get_template_parm_index): New.
(fixed_parameter_pack_p_1, fixed_parameter_pack_p): New.
-/* Handle parameterized types (templates) for GNU C++.
+/* Handle parameterized types (templates) for GNU -*- C++ -*-.
Copyright (C) 1992-2014 Free Software Foundation, Inc.
Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
Rewritten by Jason Merrill (jason@cygnus.com).
return t;
}
+/* Sentinel to disable certain warnings during template substitution. */
+
+struct warning_sentinel {
+ int &flag;
+ int val;
+ warning_sentinel(int& flag, bool suppress=true)
+ : flag(flag), val(flag) { if (suppress) flag = 0; }
+ ~warning_sentinel() { flag = val; }
+};
+
/* Like tsubst but deals with expressions and performs semantic
analysis. FUNCTION_P is true if T is the "F" in "F (ARGS)". */
op = RECUR (TREE_OPERAND (t, 0));
- ++c_inhibit_evaluation_warnings;
+ warning_sentinel s(warn_useless_cast);
switch (TREE_CODE (t))
{
case CAST_EXPR:
default:
gcc_unreachable ();
}
- --c_inhibit_evaluation_warnings;
RETURN (r);
}
case MEMBER_REF:
case DOTSTAR_EXPR:
{
- tree r;
-
- ++c_inhibit_evaluation_warnings;
-
- r = build_x_binary_op
+ warning_sentinel s1(warn_type_limits);
+ warning_sentinel s2(warn_div_by_zero);
+ tree r = build_x_binary_op
(input_location, TREE_CODE (t),
RECUR (TREE_OPERAND (t, 0)),
(TREE_NO_WARNING (TREE_OPERAND (t, 0))
if (EXPR_P (r) && TREE_NO_WARNING (t))
TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
- --c_inhibit_evaluation_warnings;
-
RETURN (r);
}
case MODOP_EXPR:
{
- tree r;
-
- ++c_inhibit_evaluation_warnings;
-
- r = build_x_modify_expr
+ warning_sentinel s(warn_div_by_zero);
+ tree r = build_x_modify_expr
(EXPR_LOCATION (t),
RECUR (TREE_OPERAND (t, 0)),
TREE_CODE (TREE_OPERAND (t, 1)),
if (TREE_NO_WARNING (t))
TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
- --c_inhibit_evaluation_warnings;
-
RETURN (r);
}
maybe_warn_about_useless_cast (tree type, tree expr, tsubst_flags_t complain)
{
if (warn_useless_cast
- && complain & tf_warning
- && c_inhibit_evaluation_warnings == 0)
+ && complain & tf_warning)
{
if (REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0);