Implement -Wswitch-fallthrough: java
Marek Polacek
polacek@redhat.com
Mon Jul 11 19:54:00 GMT 2016
2016-07-11 Marek Polacek <polacek@redhat.com>
PR c/7652
* expr.c (java_truthvalue_conversion): Add gcc_fallthrough.
(type_assertion_hasher::hash): Likewise.
* jcf-dump.c (print_constant): Likewise.
* jcf-io.c (verify_constant_pool): Likewise.
* typeck.c (promote_type): Likewise.
diff --git gcc/gcc/java/expr.c gcc/gcc/java/expr.c
index 2b856e5..d824b6c 100644
--- gcc/gcc/java/expr.c
+++ gcc/gcc/java/expr.c
@@ -192,6 +192,7 @@ java_truthvalue_conversion (tree expr)
>= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
return java_truthvalue_conversion (TREE_OPERAND (expr, 0));
/* fall through to default */
+ gcc_fallthrough ();
default:
return fold_build2 (NE_EXPR, boolean_type_node,
@@ -410,11 +411,13 @@ type_assertion_hasher::hash (type_assertion *k_p)
hash = iterative_hash (&TYPE_UID (k_p->op2), sizeof TYPE_UID (k_p->op2),
hash);
/* Fall through. */
+ gcc_fallthrough ();
case JV_ASSERT_IS_INSTANTIABLE:
hash = iterative_hash (&TYPE_UID (k_p->op1), sizeof TYPE_UID (k_p->op1),
hash);
/* Fall through. */
+ gcc_fallthrough ();
case JV_ASSERT_END_OF_TABLE:
break;
diff --git gcc/gcc/java/jcf-dump.c gcc/gcc/java/jcf-dump.c
index 1331b55..d8733ed 100644
--- gcc/gcc/java/jcf-dump.c
+++ gcc/gcc/java/jcf-dump.c
@@ -926,6 +926,8 @@ print_constant (FILE *out, JCF *jcf, int index, int verbosity)
if (verbosity > 0)
fprintf (out, "Fieldref: %ld=", (long) JPOOL_USHORT2 (jcf, index));
print_constant (out, jcf, JPOOL_USHORT2 (jcf, index), 0);
+ /* XXX Really fallthru? */
+ gcc_fallthrough ();
case 5:
case 6:
case 7:
diff --git gcc/gcc/java/jcf-io.c gcc/gcc/java/jcf-io.c
index a560db7..91d9048 100644
--- gcc/gcc/java/jcf-io.c
+++ gcc/gcc/java/jcf-io.c
@@ -472,6 +472,7 @@ verify_constant_pool (JCF *jcf)
|| JPOOL_TAG (jcf, n) != CONSTANT_Utf8)
return i;
/* ... fall through ... */
+ gcc_fallthrough ();
case CONSTANT_Class:
case CONSTANT_String:
n = JPOOL_USHORT1 (jcf, i);
diff --git gcc/gcc/java/typeck.c gcc/gcc/java/typeck.c
index d2e3db6..f7c5da4 100644
--- gcc/gcc/java/typeck.c
+++ gcc/gcc/java/typeck.c
@@ -332,6 +332,7 @@ promote_type (tree type)
case INTEGER_TYPE:
if (type == char_type_node)
return promoted_char_type_node;
+ gcc_fallthrough ();
handle_int:
if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node))
{
@@ -342,6 +343,7 @@ promote_type (tree type)
return int_type_node;
}
/* ... else fall through ... */
+ gcc_fallthrough ();
default:
return type;
}
More information about the Gcc-patches
mailing list