+2019-06-21 Matthew Beliveau <mbelivea@redhat.com>
+
+ PR c++/90875 - added -Wswitch-outside-range option
+ * c.opt (Wswitch-outside-range): Added new option.
+ * c-warn.c (c_do_switch_warnings): Use OPT_Wswitch-outside-range.
+
2019-06-21 Marek Polacek <polacek@redhat.com>
PR c++/90953 - ICE with -Wmissing-format-attribute.
min_value) >= 0)
{
location_t loc = EXPR_LOCATION ((tree) node->value);
- warning_at (loc, 0, "lower value in case label range"
- " less than minimum value for type");
+ warning_at (loc, OPT_Wswitch_outside_range,
+ "lower value in case label range less than minimum"
+ " value for type");
CASE_LOW ((tree) node->value) = convert (TREE_TYPE (cond),
min_value);
node->key = (splay_tree_key) CASE_LOW ((tree) node->value);
if (node == NULL || !node->key)
break;
location_t loc = EXPR_LOCATION ((tree) node->value);
- warning_at (loc, 0, "case label value is less than minimum "
- "value for type");
+ warning_at (loc, OPT_Wswitch_outside_range, "case label value is"
+ " less than minimum value for type");
splay_tree_remove (cases, node->key);
}
while (1);
max_value) > 0)
{
location_t loc = EXPR_LOCATION ((tree) node->value);
- warning_at (loc, 0, "upper value in case label range"
- " exceeds maximum value for type");
+ warning_at (loc, OPT_Wswitch_outside_range, "upper value in case"
+ " label range exceeds maximum value for type");
CASE_HIGH ((tree) node->value)
= convert (TREE_TYPE (cond), max_value);
outside_range_p = true;
!= NULL)
{
location_t loc = EXPR_LOCATION ((tree) node->value);
- warning_at (loc, 0,
+ warning_at (loc, OPT_Wswitch_outside_range,
"case label value exceeds maximum value for type");
splay_tree_remove (cases, node->key);
outside_range_p = true;
C ObjC C++ ObjC++ Var(warn_switch_bool) Warning Init(1)
Warn about switches with boolean controlling expression.
+Wswitch-outside-range
+C ObjC C++ ObjC++ Var(warn_switch_outside_range) Warning Init(1)
+Warn about switch values that are outside of the switch's type range.
+
Wtemplates
C++ ObjC++ Var(warn_templates) Warning
Warn on primary template declaration.
@end smallexample
This warning is enabled by default for C and C++ programs.
+@item -Wswitch-outside-range
+@opindex Wswitch-outside-range
+@opindex Wno-switch-outside-range
+Warn whenever a @code{switch} case has a value that is outside of its
+respective type range. This warning is enabled by default for
+C and C++ programs.
+
@item -Wswitch-unreachable
@opindex Wswitch-unreachable
@opindex Wno-switch-unreachable
+2019-06-21 Matthew Beliveau <mbelivea@redhat.com>
+
+ PR c++/90875 - added -Wswitch-outside-range option
+ * c-c++-common/Wswitch-outside-range-1.c: New test.
+ * c-c++-common/Wswitch-outside-range-2.c: New test.
+ * c-c++-common/Wswitch-outside-range-3.c: New test.
+ * c-c++-common/Wswitch-outside-range-4.c: New test.
+
2019-06-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/51991