aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f356caa..2fa1549f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-03 Marek Polacek <polacek@redhat.com>
+
+ PR c/60439
+ * semantics.c (finish_switch_cond): Warn if switch condition has
+ boolean value.
+
2014-06-03 Jason Merrill <jason@redhat.com>
PR c++/60992
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 21920b4..c1c16f4 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1130,6 +1130,11 @@ finish_switch_cond (tree cond, tree switch_stmt)
orig_type = TREE_TYPE (cond);
if (cond != error_mark_node)
{
+ /* Warn if the condition has boolean value. */
+ if (TREE_CODE (orig_type) == BOOLEAN_TYPE)
+ warning_at (input_location, OPT_Wswitch_bool,
+ "switch condition has type bool");
+
/* [stmt.switch]
Integral promotions are performed. */