diff mbox

Implement -Wswitch-fallthrough: c/

Message ID 20160711194959.GK13963@redhat.com
State New
Headers show

Commit Message

Marek Polacek July 11, 2016, 7:49 p.m. UTC
2016-07-11  Marek Polacek  <polacek@redhat.com>

	PR c/7652
	* c-array-notation.c (expand_array_notations): Add gcc_fallthrough.
	* c-decl.c (pop_scope): Likewise.
	(grokdeclarator): Likewise.
	(get_parm_info): Likewise.
	* c-objc-common.c (c_tree_printer): Likewise.
	* c-parser.c (c_parser_external_declaration): Likewise.
	(c_parser_declspecs): Likewise.
	(c_parser_statement_after_labels): Likewise.
	(c_parser_postfix_expression): Likewise.
	(c_parser_check_literal_zero): Likewise.
	(c_parser_omp_variable_list): Likewise.
	(c_parser_omp_for_loop): Likewise.
	* c-typeck.c (composite_type): Likewise.
	(build_unary_op): Likewise.
	(c_mark_addressable): Likewise.
	(build_binary_op): Likewise.
	(c_finish_omp_clauses): Likewise.
diff mbox

Patch

diff --git gcc/gcc/c/c-array-notation.c gcc/gcc/c/c-array-notation.c
index c7cf66a..cf91b21 100644
--- gcc/gcc/c/c-array-notation.c
+++ gcc/gcc/c/c-array-notation.c
@@ -1303,6 +1303,7 @@  expand_array_notations (tree *tp, int *walk_subtrees, void *)
 	 A[x:y];
 	 Replace those with just void zero node.  */
       *tp = void_node;
+      gcc_fallthrough ();
     default:
       break;
     }
diff --git gcc/gcc/c/c-decl.c gcc/gcc/c/c-decl.c
index 8b966fe..d3d3bda 100644
--- gcc/gcc/c/c-decl.c
+++ gcc/gcc/c/c-decl.c
@@ -1284,6 +1284,7 @@  pop_scope (void)
 	    }
 
 	  /* Fall through.  */
+	  gcc_fallthrough ();
 	case TYPE_DECL:
 	case CONST_DECL:
 	common_symbol:
@@ -1329,6 +1330,7 @@  pop_scope (void)
 	    }
 
 	  /* Fall through.  */
+	  gcc_fallthrough ();
 	  /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have
 	     already been put there by store_parm_decls.  Unused-
 	     parameter warnings are handled by function.c.
@@ -5564,6 +5566,7 @@  grokdeclarator (const struct c_declarator *declarator,
 	case cdk_array:
 	  loc = decl->id_loc;
 	  /* FALL THRU.  */
+	  gcc_fallthrough ();
 
 	case cdk_function:
 	case cdk_pointer:
@@ -7250,6 +7253,7 @@  get_parm_info (bool ellipsis, tree expr)
 	  DECL_CHAIN (decl) = others;
 	  others = decl;
 	  /* fall through */
+	  gcc_fallthrough ();
 
 	case ERROR_MARK:
 	set_shadowed:
diff --git gcc/gcc/c/c-objc-common.c gcc/gcc/c/c-objc-common.c
index 20dc024..21c0e2c 100644
--- gcc/gcc/c/c-objc-common.c
+++ gcc/gcc/c/c-objc-common.c
@@ -112,6 +112,7 @@  c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
 	    }
 	}
       /* FALLTHRU */
+      gcc_fallthrough ();
 
     case 'F':
       if (DECL_NAME (t))
diff --git gcc/gcc/c/c-parser.c gcc/gcc/c/c-parser.c
index 1a50dea..0a33728 100644
--- gcc/gcc/c/c-parser.c
+++ gcc/gcc/c/c-parser.c
@@ -1546,6 +1546,7 @@  c_parser_external_declaration (c_parser *parser)
 	}
       /* Else fall through, and yield a syntax error trying to parse
 	 as a declaration or function definition.  */
+      gcc_fallthrough ();
     default:
     decl_or_fndef:
       /* A declaration or a function definition (or, in Objective-C,
@@ -2517,6 +2518,7 @@  c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
 	  if (!auto_type_ok)
 	    goto out;
 	  /* Fall through.  */
+	  gcc_fallthrough ();
 	case RID_UNSIGNED:
 	case RID_LONG:
 	case RID_SHORT:
@@ -5339,6 +5341,7 @@  c_parser_statement_after_labels (c_parser *parser, bool *if_p,
     default:
     expr_stmt:
       stmt = c_finish_expr_stmt (loc, c_parser_expression_conv (parser).value);
+      gcc_fallthrough ();
     expect_semicolon:
       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
       break;
@@ -8174,6 +8177,7 @@  c_parser_postfix_expression (c_parser *parser)
 	  break;
 	}
       /* Else fall through to report error.  */
+      gcc_fallthrough ();
     default:
       c_parser_error (parser, "expected expression");
       expr.set_error ();
@@ -8578,6 +8582,7 @@  c_parser_check_literal_zero (c_parser *parser, unsigned *literal_zero_mask,
 	  && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
 	      || c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_PAREN))
 	*literal_zero_mask |= 1U << idx;
+      gcc_fallthrough ();
     default:
       break;
     }
@@ -10672,6 +10677,7 @@  c_parser_omp_variable_list (c_parser *parser,
 		  break;
 		}
 	      /* FALLTHROUGH  */
+	      gcc_fallthrough ();
 	    case OMP_CLAUSE_MAP:
 	    case OMP_CLAUSE_FROM:
 	    case OMP_CLAUSE_TO:
@@ -10693,6 +10699,7 @@  c_parser_omp_variable_list (c_parser *parser,
 		  t = build_component_ref (op_loc, t, ident, comp_loc);
 		}
 	      /* FALLTHROUGH  */
+	      gcc_fallthrough ();
 	    case OMP_CLAUSE_DEPEND:
 	    case OMP_CLAUSE_REDUCTION:
 	      while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
@@ -14394,6 +14401,7 @@  restart:
       if (code == OMP_ATOMIC_CAPTURE_NEW && !structured_block)
 	code = OMP_ATOMIC_CAPTURE_OLD;
       /* FALLTHROUGH */
+      gcc_fallthrough ();
     case PREINCREMENT_EXPR:
       lhs = TREE_OPERAND (lhs, 0);
       unfolded_lhs = NULL_TREE;
@@ -14405,6 +14413,7 @@  restart:
       if (code == OMP_ATOMIC_CAPTURE_NEW && !structured_block)
 	code = OMP_ATOMIC_CAPTURE_OLD;
       /* FALLTHROUGH */
+      gcc_fallthrough ();
     case PREDECREMENT_EXPR:
       lhs = TREE_OPERAND (lhs, 0);
       unfolded_lhs = NULL_TREE;
@@ -14423,6 +14432,7 @@  restart:
 	/* Undo effects of boolean_increment for post {in,de}crement.  */
 	lhs = TREE_OPERAND (TREE_OPERAND (lhs, 1), 0);
       /* FALLTHRU */
+      gcc_fallthrough ();
     case MODIFY_EXPR:
       if (TREE_CODE (lhs) == MODIFY_EXPR
 	  && TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) == BOOLEAN_TYPE)
@@ -14458,6 +14468,7 @@  restart:
 	    }
 	}
       /* FALLTHRU */
+      gcc_fallthrough ();
     default:
       if (!lvalue_p (unfolded_lhs))
 	lhs = non_lvalue (lhs);
@@ -14863,6 +14874,7 @@  c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code,
 	      if (code == CILK_SIMD || code == CILK_FOR)
 		break;
 	      /* FALLTHRU.  */
+	      gcc_fallthrough ();
 	    default:
 	      /* Can't be cond = error_mark_node, because we want to preserve
 		 the location until c_finish_omp_for.  */
diff --git gcc/gcc/c/c-typeck.c gcc/gcc/c/c-typeck.c
index bafd0d2..4c1d775 100644
--- gcc/gcc/c/c-typeck.c
+++ gcc/gcc/c/c-typeck.c
@@ -607,6 +607,7 @@  composite_type (tree t1, tree t2)
 	t1 = qualify_type (t1, t2);
 	/* ... falls through ...  */
       }
+    gcc_fallthrough ();
 
     default:
       return build_type_attribute_variant (t1, attributes);
@@ -4494,6 +4495,7 @@  build_unary_op (location_t location,
 	    }
 
 	  /* ... fall through ...  */
+	  gcc_fallthrough ();
 
 	case ARRAY_REF:
 	  if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
@@ -4512,6 +4514,7 @@  build_unary_op (location_t location,
 			    "address of array with reverse scalar storage "
 			    "order requested");
 	    }
+	  gcc_fallthrough ();
 
 	default:
 	  break;
@@ -4696,9 +4699,11 @@  c_mark_addressable (tree exp)
 	  }
 
 	/* drops in */
+	gcc_fallthrough ();
       case FUNCTION_DECL:
 	TREE_ADDRESSABLE (x) = 1;
 	/* drops out */
+	gcc_fallthrough ();
       default:
 	return true;
     }
@@ -11464,6 +11469,7 @@  build_binary_op (location_t location, enum tree_code code,
 		  op1 = c_save_expr (op1);
 		  imag = build2 (resultcode, real_type, imag, op1);
 		  /* Fall through.  */
+		  gcc_fallthrough ();
 		case PLUS_EXPR:
 		case MINUS_EXPR:
 		  real = build2 (resultcode, real_type, real, op1);
@@ -11485,6 +11491,7 @@  build_binary_op (location_t location, enum tree_code code,
 		  op0 = c_save_expr (op0);
 		  imag = build2 (resultcode, real_type, op0, imag);
 		  /* Fall through.  */
+		  gcc_fallthrough ();
 		case PLUS_EXPR:
 		  real = build2 (resultcode, real_type, op0, real);
 		  break;
@@ -12944,6 +12951,7 @@  c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 
 	check_dup_generic:
 	  t = OMP_CLAUSE_DECL (c);
+	  gcc_fallthrough ();
 	check_dup_generic_t:
 	  if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
 	    {