This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement -Wswitch-fallthrough: c-family/


2016-07-11  Marek Polacek  <polacek@redhat.com>

	PR c/7652
	* c-ada-spec.c (print_ada_macros): Add gcc_fallthrough.
	(to_ada_name): Likewise.
	(dump_generic_ada_node): Likewise.
	(dump_nested_type): Likewise.
	* c-common.c (warn_if_unused_value): Likewise.
	(sizeof_pointer_memaccess_warning): Likewise.
	(c_common_truthvalue_conversion): Likewise.
	(handle_tm_attribute): Likewise.
	(c_cpp_error): Likewise.
	(resolve_overloaded_builtin): Likewise.
	(scalar_to_vector): Likewise.
	* c-gimplify.c (c_gimplify_expr):  Likewise.
	* c-lex.c (c_lex_with_flags): Likewise.
	(lex_string): Likewise.
	* c-omp.c (c_finish_omp_for): Likewise.
	* c-opts.c (c_common_handle_option): Likewise.
	* c-pragma.c (handle_pragma_pack): Likewise.
	* c-pretty-print.c (c_pretty_printer::postfix_expression): Likewise.
	* cilk.c (extract_free_variables): Likewise.

diff --git gcc/gcc/c-family/c-ada-spec.c gcc/gcc/c-family/c-ada-spec.c
index e33fdff..04a918f 100644
--- gcc/gcc/c-family/c-ada-spec.c
+++ gcc/gcc/c-family/c-ada-spec.c
@@ -288,6 +288,7 @@ print_ada_macros (pretty_printer *pp, cpp_hashnode **macros, int max_ada_macros)
 		        break;
 		      }
 		    /* fallthrough */
+		    gcc_fallthrough ();
 
 		  case CPP_RSHIFT:
 		  case CPP_COMPL:
@@ -1182,6 +1183,7 @@ to_ada_name (const char *name, int *space_found)
 	  if (len2 && s[len2 - 1] == '_')
 	    s[len2++] = 'u';
 	  /* fall through */
+	  gcc_fallthrough ();
 
 	default:
 	  s[len2++] = name[j];
@@ -1862,6 +1864,8 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
     case TREE_BINFO:
       dump_generic_ada_node
 	(buffer, BINFO_TYPE (node), type, spc, limited_access, name_only);
+      /* XXX Really fallthru?  */
+      gcc_fallthrough ();
 
     case TREE_VEC:
       pp_string (buffer, "--- unexpected node: TREE_VEC");
@@ -2585,6 +2589,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent,
 	      pp_string (buffer, ");");
 	    }
 	}
+      gcc_fallthrough ();
 
     default:
       break;
diff --git gcc/gcc/c-family/c-common.c gcc/gcc/c-family/c-common.c
index 936ddfb..0f5f65a 100644
--- gcc/gcc/c-family/c-common.c
+++ gcc/gcc/c-family/c-common.c
@@ -1506,6 +1506,7 @@ warn_if_unused_value (const_tree exp, location_t locus)
 	  goto restart;
 	}
       /* Fall through.  */
+     gcc_fallthrough ();
 
     default:
       /* Referencing a volatile value is a side effect, so don't warn.  */
@@ -1518,6 +1519,7 @@ warn_if_unused_value (const_tree exp, location_t locus)
 	 but front ends may define such.  */
       if (EXPRESSION_CLASS_P (exp) && TREE_OPERAND_LENGTH (exp) == 0)
 	return false;
+      gcc_fallthrough ();
 
     warn:
       return warning_at (locus, OPT_Wunused_value, "value computed is not used");
@@ -1629,6 +1631,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
     case BUILT_IN_STRNCASECMP:
       cmp = true;
       /* FALLTHRU */
+      gcc_fallthrough ();
     case BUILT_IN_STRNCPY:
     case BUILT_IN_STRNCPY_CHK:
     case BUILT_IN_STRNCAT:
@@ -1637,6 +1640,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
     case BUILT_IN_STPNCPY_CHK:
       strop = true;
       /* FALLTHRU */
+      gcc_fallthrough ();
     case BUILT_IN_MEMCPY:
     case BUILT_IN_MEMCPY_CHK:
     case BUILT_IN_MEMMOVE:
@@ -4468,6 +4472,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
     case FUNCTION_DECL:
       expr = build_unary_op (location, ADDR_EXPR, expr, 0);
       /* Fall through.  */
+      gcc_fallthrough ();
 
     case ADDR_EXPR:
       {
@@ -8739,6 +8744,7 @@ handle_tm_attribute (tree *node, tree name, tree args,
       if (tm_attr_to_mask (name) & ~(TM_ATTR_SAFE | TM_ATTR_CALLABLE))
 	goto ignored;
       /* FALLTHRU */
+      gcc_fallthrough ();
 
     case FUNCTION_TYPE:
     case METHOD_TYPE:
@@ -8782,11 +8788,13 @@ handle_tm_attribute (tree *node, tree name, tree args,
 	  }
       }
       /* FALLTHRU */
+      gcc_fallthrough ();
 
     default:
       /* If a function is next, pass it on to be tried next.  */
       if (flags & (int) ATTR_FLAG_FUNCTION_NEXT)
 	return tree_cons (name, args, NULL);
+      gcc_fallthrough ();
 
     ignored:
       warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -10253,6 +10261,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
 	return false;
       global_dc->dc_warn_system_headers = 1;
       /* Fall through.  */
+      gcc_fallthrough ();
     case CPP_DL_WARNING:
       if (flag_no_output)
 	return false;
@@ -11450,6 +11459,7 @@ resolve_overloaded_builtin (location_t loc, tree function,
       {
 	fetch_op = false;
 	/* Fallthrough to further processing.  */
+	gcc_fallthrough ();
       }
     case BUILT_IN_ATOMIC_ADD_FETCH_N:
     case BUILT_IN_ATOMIC_SUB_FETCH_N:
@@ -11466,6 +11476,7 @@ resolve_overloaded_builtin (location_t loc, tree function,
       {
         orig_format = false;
 	/* Fallthru for parameter processing.  */
+	gcc_fallthrough ();
       }
     case BUILT_IN_SYNC_FETCH_AND_ADD_N:
     case BUILT_IN_SYNC_FETCH_AND_SUB_N:
@@ -12623,6 +12634,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1,
       case BIT_AND_EXPR:
 	integer_only_op = true;
 	/* ... fall through ...  */
+	gcc_fallthrough ();
 
       case VEC_COND_EXPR:
 
@@ -12678,6 +12690,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1,
 	      }
 	    return ret;
 	  }
+	gcc_fallthrough ();
       default:
 	break;
     }
diff --git gcc/gcc/c-family/c-gimplify.c gcc/gcc/c-family/c-gimplify.c
index c18b057..a7a7189 100644
--- gcc/gcc/c-family/c-gimplify.c
+++ gcc/gcc/c-family/c-gimplify.c
@@ -295,6 +295,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
 	  cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p);
 	  return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
 	}
+      gcc_fallthrough ();
 
     default:;
     }
diff --git gcc/gcc/c-family/c-lex.c gcc/gcc/c-family/c-lex.c
index 8f33d86..634cd20 100644
--- gcc/gcc/c-family/c-lex.c
+++ gcc/gcc/c-family/c-lex.c
@@ -493,6 +493,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
 		  break;
 		}
 	      /* FALLTHROUGH */
+	      gcc_fallthrough ();
 
 	    default:
 	      /* ... or not.  */
@@ -504,6 +505,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
 	}
 
       /* FALLTHROUGH */
+      gcc_fallthrough ();
     case CPP_HASH:
     case CPP_PASTE:
       {
@@ -1127,6 +1129,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
 	  goto retry;
 	}
       /* FALLTHROUGH */
+      gcc_fallthrough ();
 
     default:
       break;
@@ -1142,6 +1145,8 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
 	  else
 	    error ("unsupported non-standard concatenation of string literals");
 	}
+      /* XXX Really fallthru?  */
+      gcc_fallthrough ();
 
     case CPP_STRING:
       if (!concats)
diff --git gcc/gcc/c-family/c-omp.c gcc/gcc/c-family/c-omp.c
index 1691c40..c0a3e9a 100644
--- gcc/gcc/c-family/c-omp.c
+++ gcc/gcc/c-family/c-omp.c
@@ -634,6 +634,7 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv,
 		break;
 	      incr = TREE_OPERAND (incr, 1);
 	      /* FALLTHRU */
+	      gcc_fallthrough ();
 	    case MODIFY_EXPR:
 	      if (TREE_OPERAND (incr, 0) != decl)
 		break;
diff --git gcc/gcc/c-family/c-opts.c gcc/gcc/c-family/c-opts.c
index ff6339c..cb7728d 100644
--- gcc/gcc/c-family/c-opts.c
+++ gcc/gcc/c-family/c-opts.c
@@ -437,6 +437,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
     case OPT_ffreestanding:
       value = !value;
       /* Fall through....  */
+      gcc_fallthrough ();
     case OPT_fhosted:
       flag_hosted = value;
       flag_no_builtin = !value;
@@ -479,6 +480,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       if (value)
 	value = 2;
       /* Fall Through.  */
+      gcc_fallthrough ();
 
     case OPT_ftrack_macro_expansion_:
       if (arg && *arg != '\0')
diff --git gcc/gcc/c-family/c-pragma.c gcc/gcc/c-family/c-pragma.c
index 277bc56..6d38358 100644
--- gcc/gcc/c-family/c-pragma.c
+++ gcc/gcc/c-family/c-pragma.c
@@ -214,6 +214,8 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy))
 	    align = maximum_field_alignment;
 	    break;
 	  }
+	/* XXX Really fallthru?  */
+	gcc_fallthrough ();
       default:
 	GCC_BAD2 ("alignment must be a small power of two, not %d", align);
       }
diff --git gcc/gcc/c-family/c-pretty-print.c gcc/gcc/c-family/c-pretty-print.c
index 704d21d..c9ff725 100644
--- gcc/gcc/c-family/c-pretty-print.c
+++ gcc/gcc/c-family/c-pretty-print.c
@@ -1643,6 +1643,7 @@ c_pretty_printer::postfix_expression (tree e)
     case COMPOUND_LITERAL_EXPR:
       e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
       /* Fall through.  */
+      gcc_fallthrough ();
     case CONSTRUCTOR:
       initializer (e);
       break;
@@ -1663,6 +1664,7 @@ c_pretty_printer::postfix_expression (tree e)
 	  break;
 	}
       /* else fall through.  */
+      gcc_fallthrough ();
 
     default:
       primary_expression (e);
diff --git gcc/gcc/c-family/cilk.c gcc/gcc/c-family/cilk.c
index 8f34cd6..87ba9f6 100644
--- gcc/gcc/c-family/cilk.c
+++ gcc/gcc/c-family/cilk.c
@@ -1096,6 +1096,7 @@ extract_free_variables (tree t, struct wrapper_data *wd,
     case RESULT_DECL:
       if (wd->type != CILK_BLOCK_SPAWN)
 	TREE_ADDRESSABLE (t) = 1;
+      gcc_fallthrough ();
     case VAR_DECL:
     case PARM_DECL:
       if (!is_global_var (t))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]