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: [warning control patch] simple cases


> Sorry to be such a pain, but this patch introduces quite a few
> overly-long lines.  I guess most of them could be cured by moving
> the string to the next line, but as I understand it, you're allowed
> to use string concatenation these days anyway.

Fixed...

2005-05-18  DJ Delorie  <dj@redhat.com>

	* c-common.c (unsigned_conversion_warning): Move warning control
	from if() to warning(OPT_*).
	(c_common_truthvalue_conversion): Likewise.
	(c_do_switch_warnings): Likewise.
	* c-decl.c (diagnose_mismatched_decls): Likewise.
	(diagnose_mismatched_decls): Likewise.
	(define_label): Likewise.
	(grokdeclarator): Likewise.
	* c-format.c (check_format_info): Likewise.
	* c-lex.c (interpret_integer): Likwise.
	(lex_string): Likewise.
	* c-opts.c (c_common_post_options): Likewise.
	* c-parser.c (c_parser_unary_expression): Likewise.
	* c-pragma.c (handle_pragma_redefine_extname): Likewise.
	(handle_pragma_extern_prefix): Likewise.
	* c-typeck.c (build_binary_op): Likewise.
	* gcse.c (is_too_expensive): Likewise.
	* opts.c (decode_options): Likewise.
	* stor-layout.c (place_field): Likewise.
	* tree-cfg.c (remove_bb): Likewise.
	
	* c.opt (-Wreturn-type): Add Var(warn_return_type).
	* flags.h (warn_return_type): Remove.
	* toplev.c (warn_return_type): Likewise.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.630
diff -p -U3 -r1.630  c-common.c
--- c-common.c	17 May 2005 20:11:31 -0000	1.630
+++ c-common.c	19 May 2005 02:01:31 -0000
@@ -945,8 +945,9 @@ unsigned_conversion_warning (tree result
       if (!int_fits_type_p (operand, c_common_signed_type (type)))
 	/* This detects cases like converting -129 or 256 to unsigned char.  */
 	warning (0, "large integer implicitly truncated to unsigned type");
-      else if (warn_conversion)
-	warning (0, "negative integer implicitly converted to unsigned type");
+      else
+	warning (OPT_Wconversion,
+		 "negative integer implicitly converted to unsigned type");
     }
 }
 
@@ -2470,8 +2471,9 @@ c_common_truthvalue_conversion (tree exp
       break;
 
     case MODIFY_EXPR:
-      if (warn_parentheses && !TREE_NO_WARNING (expr))
-	warning (0, "suggest parentheses around assignment used as truth value");
+      if (!TREE_NO_WARNING (expr))
+	warning (OPT_Wparentheses,
+		 "suggest parentheses around assignment used as truth value");
       break;
 
     default:
@@ -3725,8 +3727,9 @@ c_do_switch_warnings (splay_tree cases, 
     return;
 
   default_node = splay_tree_lookup (cases, (splay_tree_key) NULL);
-  if (warn_switch_default && !default_node)
-    warning (0, "%Hswitch missing default case", &switch_location);
+  if (!default_node)
+    warning (OPT_Wswitch_default, "%Hswitch missing default case",
+	     &switch_location);
 
   /* If the switch expression was an enumerated type, check that
      exactly all enumeration literals are covered by the cases.
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.656
diff -p -U3 -r1.656  c-decl.c
--- c-decl.c	17 May 2005 20:11:34 -0000	1.656
+++ c-decl.c	19 May 2005 02:01:32 -0000
@@ -1172,9 +1172,9 @@ diagnose_mismatched_decls (tree newdecl,
       else if (TREE_PUBLIC (newdecl))
 	warning (0, "%Jbuilt-in function %qD declared as non-function",
 		 newdecl, newdecl);
-      else if (warn_shadow)
-	warning (0, "%Jdeclaration of %qD shadows a built-in function",
-		 newdecl, newdecl);
+      else
+	warning (OPT_Wshadow, "%Jdeclaration of %qD shadows "
+		 "a built-in function", newdecl, newdecl);
       return false;
     }
 
@@ -1288,9 +1288,8 @@ diagnose_mismatched_decls (tree newdecl,
 	      || (DECL_INITIAL (newdecl)
 		  && !TYPE_ARG_TYPES (TREE_TYPE (newdecl)))))
 	{
-	  if (warn_shadow)
-	    warning (0, "%Jdeclaration of %qD shadows a built-in function",
-		     newdecl, newdecl);
+	  warning (OPT_Wshadow, "%Jdeclaration of %qD shadows "
+		   "a built-in function", newdecl, newdecl);
 	  /* Discard the old built-in function.  */
 	  return false;
 	}
@@ -2561,9 +2560,9 @@ define_label (location_t location, tree 
 	    /*invisible=*/false, /*nested=*/false);
     }
 
-  if (warn_traditional && !in_system_header && lookup_name (name))
-    warning (0, "%Htraditional C lacks a separate namespace for labels, "
-             "identifier %qE conflicts", &location, name);
+  if (!in_system_header && lookup_name (name))
+    warning (OPT_Wtraditional, "%Htraditional C lacks a separate namespace "
+             "for labels, identifier %qE conflicts", &location, name);
 
   nlist_se = XOBNEW (&parser_obstack, struct c_label_list);
   nlist_se->next = label_context_stack_se->labels_def;
@@ -4289,8 +4288,9 @@ grokdeclarator (const struct c_declarato
 		   them for noreturn functions.  */
 		if (VOID_TYPE_P (type) && really_funcdef)
 		  pedwarn ("function definition has qualified void return type");
-		else if (warn_return_type)
-		  warning (0, "type qualifiers ignored on function return type");
+		else
+		  warning (OPT_Wreturn_type,
+			   "type qualifiers ignored on function return type");
 		
 		type = c_build_qualified_type (type, type_quals);
 	      }
@@ -6097,7 +6097,8 @@ store_parm_decls_oldstyle (tree fndecl, 
 #endif
 
   if (!in_system_header)
-    warning (OPT_Wold_style_definition, "%Jold-style function definition", fndecl);
+    warning (OPT_Wold_style_definition, "%Jold-style function definition",
+	     fndecl);
 
   /* Match each formal parameter name with its declaration.  Save each
      decl in the appropriate TREE_PURPOSE slot of the parmids chain.  */
Index: c-format.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-format.c,v
retrieving revision 1.75
diff -p -U3 -r1.75  c-format.c
--- c-format.c	13 May 2005 09:48:06 -0000	1.75
+++ c-format.c	19 May 2005 02:01:32 -0000
@@ -1140,8 +1140,8 @@ check_format_info (function_format_info 
 	{
 	  /* For strftime-like formats, warn for not checking the format
 	     string; but there are no arguments to check.  */
-	  if (warn_format_nonliteral)
-	    warning (0, "format not a string literal, format string not checked");
+	  warning (OPT_Wformat_nonliteral,
+		   "format not a string literal, format string not checked");
 	}
       else if (info->first_arg_num != 0)
 	{
@@ -1154,10 +1154,15 @@ check_format_info (function_format_info 
 	      params = TREE_CHAIN (params);
 	      ++arg_num;
 	    }
-	  if (params == 0 && (warn_format_nonliteral || warn_format_security))
-	    warning (0, "format not a string literal and no format arguments");
-	  else if (warn_format_nonliteral)
-	    warning (0, "format not a string literal, argument types not checked");
+	  if (params == 0 && warn_format_security)
+	    warning (OPT_Wformat_security,
+		     "format not a string literal and no format arguments");
+	  else if (params == 0 && warn_format_nonliteral)
+	    warning (OPT_Wformat_nonliteral,
+		     "format not a string literal and no format arguments");
+	  else
+	    warning (OPT_Wformat_nonliteral,
+		     "format not a string literal, argument types not checked");
 	}
     }
 
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.247
diff -p -U3 -r1.247  c-lex.c
--- c-lex.c	23 Apr 2005 21:27:31 -0000	1.247
+++ c-lex.c	19 May 2005 02:01:32 -0000
@@ -599,8 +599,9 @@ interpret_integer (const cpp_token *toke
 		  itk = itk_u;
 		  warning (0, "this decimal constant is unsigned only in ISO C90");
 		}
-	      else if (warn_traditional)
-		warning (0, "this decimal constant would be unsigned in ISO C90");
+	      else
+		warning (OPT_Wtraditional,
+			 "this decimal constant would be unsigned in ISO C90");
 	    }
 	}
     }
@@ -763,8 +764,9 @@ lex_string (const cpp_token *tok, tree *
   if (concats)
     strs = (cpp_string *) obstack_finish (&str_ob);
 
-  if (concats && !objc_string && warn_traditional && !in_system_header)
-    warning (0, "traditional C rejects string constant concatenation");
+  if (concats && !objc_string && !in_system_header)
+    warning (OPT_Wtraditional,
+	     "traditional C rejects string constant concatenation");
 
   if ((c_lex_string_translate
        ? cpp_interpret_string : cpp_interpret_string_notranslate)
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.145
diff -p -U3 -r1.145  c-opts.c
--- c-opts.c	18 May 2005 20:45:09 -0000	1.145
+++ c-opts.c	19 May 2005 02:01:32 -0000
@@ -979,18 +979,21 @@ c_common_post_options (const char **pfil
 
   /* Special format checking options don't work without -Wformat; warn if
      they are used.  */
-  if (warn_format_y2k && !warn_format)
-    warning (0, "-Wformat-y2k ignored without -Wformat");
-  if (warn_format_extra_args && !warn_format)
-    warning (0, "-Wformat-extra-args ignored without -Wformat");
-  if (warn_format_zero_length && !warn_format)
-    warning (0, "-Wformat-zero-length ignored without -Wformat");
-  if (warn_format_nonliteral && !warn_format)
-    warning (0, "-Wformat-nonliteral ignored without -Wformat");
-  if (warn_format_security && !warn_format)
-    warning (0, "-Wformat-security ignored without -Wformat");
-  if (warn_missing_format_attribute && !warn_format)
-    warning (0, "-Wmissing-format-attribute ignored without -Wformat");
+  if (!warn_format)
+    {
+      warning (OPT_Wformat_y2k,
+	       "-Wformat-y2k ignored without -Wformat");
+      warning (OPT_Wformat_extra_args,
+	       "-Wformat-extra-args ignored without -Wformat");
+      warning (OPT_Wformat_zero_length,
+	       "-Wformat-zero-length ignored without -Wformat");
+      warning (OPT_Wformat_nonliteral,
+	       "-Wformat-nonliteral ignored without -Wformat");
+      warning (OPT_Wformat_security,
+	       "-Wformat-security ignored without -Wformat");
+      warning (OPT_Wmissing_format_attribute,
+	       "-Wmissing-format-attribute ignored without -Wformat");
+    }
 
   /* C99 requires special handling of complex multiplication and division;
      -ffast-math and -fcx-limited-range are handled in process_options.  */
Index: c-parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parser.c,v
retrieving revision 2.13
diff -p -U3 -r2.13  c-parser.c
--- c-parser.c	9 May 2005 20:48:33 -0000	2.13
+++ c-parser.c	19 May 2005 02:01:32 -0000
@@ -4518,8 +4518,9 @@ c_parser_unary_expression (c_parser *par
       return ret;
     case CPP_PLUS:
       c_parser_consume_token (parser);
-      if (!c_dialect_objc () && warn_traditional && !in_system_header)
-	warning (0, "traditional C rejects the unary plus operator");
+      if (!c_dialect_objc () && !in_system_header)
+	warning (OPT_Wtraditional,
+		 "traditional C rejects the unary plus operator");
       return parser_build_unary_op (CONVERT_EXPR,
 				    c_parser_cast_expression (parser, NULL));
     case CPP_MINUS:
Index: c-pragma.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pragma.c,v
retrieving revision 1.84
diff -p -U3 -r1.84  c-pragma.c
--- c-pragma.c	28 Apr 2005 05:38:30 -0000	1.84
+++ c-pragma.c	19 May 2005 02:01:32 -0000
@@ -418,7 +418,8 @@ handle_pragma_redefine_extname (cpp_read
   if (!flag_mudflap && !targetm.handle_pragma_redefine_extname)
     {
       if (warn_unknown_pragmas > in_system_header)
-	warning (0, "#pragma redefine_extname not supported on this target");
+	warning (OPT_Wunknown_pragmas,
+		 "#pragma redefine_extname not supported on this target");
       return;
     }
 
@@ -486,7 +487,8 @@ handle_pragma_extern_prefix (cpp_reader 
     /* Note that the length includes the null terminator.  */
     pragma_extern_prefix = (TREE_STRING_LENGTH (prefix) > 1 ? prefix : NULL);
   else if (warn_unknown_pragmas > in_system_header)
-    warning (0, "#pragma extern_prefix not supported on this target");
+    warning (OPT_Wunknown_pragmas,
+	     "#pragma extern_prefix not supported on this target");
 }
 
 /* Hook from the front ends to apply the results of one of the preceding
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.444
diff -p -U3 -r1.444  c-typeck.c
--- c-typeck.c	17 May 2005 20:11:38 -0000	1.444
+++ c-typeck.c	19 May 2005 02:01:33 -0000
@@ -7509,8 +7509,8 @@ build_binary_op (enum tree_code code, tr
     case EXACT_DIV_EXPR:
       /* Floating point division by zero is a legitimate way to obtain
 	 infinities and NaNs.  */
-      if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1))
-	warning (0, "division by zero");
+      if (skip_evaluation == 0 && integer_zerop (op1))
+	warning (OPT_Wdiv_by_zero, "division by zero");
 
       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
 	   || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
@@ -7548,8 +7548,8 @@ build_binary_op (enum tree_code code, tr
 
     case TRUNC_MOD_EXPR:
     case FLOOR_MOD_EXPR:
-      if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1))
-	warning (0, "division by zero");
+      if (skip_evaluation == 0 && integer_zerop (op1))
+	warning (OPT_Wdiv_by_zero, "division by zero");
 
       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
 	{
@@ -7641,8 +7641,9 @@ build_binary_op (enum tree_code code, tr
 
     case EQ_EXPR:
     case NE_EXPR:
-      if (warn_float_equal && (code0 == REAL_TYPE || code1 == REAL_TYPE))
-	warning (0, "comparing floating point with == or != is unsafe");
+      if (code0 == REAL_TYPE || code1 == REAL_TYPE)
+	warning (OPT_Wfloat_equal,
+		 "comparing floating point with == or != is unsafe");
       /* Result of comparison is always int,
 	 but don't convert the args to int!  */
       build_type = integer_type_node;
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.44
diff -p -U3 -r1.44  c.opt
--- c.opt	18 May 2005 20:45:09 -0000	1.44
+++ c.opt	19 May 2005 02:01:33 -0000
@@ -339,7 +339,7 @@ C++ ObjC++ Var(warn_reorder)
 Warn when the compiler reorders code
 
 Wreturn-type
-C ObjC C++ ObjC++
+C ObjC C++ ObjC++ Var(warn_return_type)
 Warn whenever a function's return type defaults to \"int\" (C), or about inconsistent return types (C++)
 
 Wselector
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.152
diff -p -U3 -r1.152  flags.h
--- flags.h	13 Feb 2005 19:05:03 -0000	1.152
+++ flags.h	19 May 2005 02:01:33 -0000
@@ -101,11 +101,6 @@ extern bool extra_warnings;
 
 extern void set_Wunused (int setting);
 
-/* Nonzero means warn about function definitions that default the return type
-   or that use a null return and have a return-type other than void.  */
-
-extern int warn_return_type;
-
 /* Nonzero means warn about any objects definitions whose size is larger
    than N bytes.  Also want about function definitions whose returned
    values are larger than N bytes. The value N is in `larger_than_size'.  */
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.341
diff -p -U3 -r1.341  gcse.c
--- gcse.c	9 May 2005 17:52:16 -0000	1.341
+++ gcse.c	19 May 2005 02:01:33 -0000
@@ -6529,9 +6529,9 @@ is_too_expensive (const char *pass)
      graceful degradation.  */
   if (n_edges > 20000 + n_basic_blocks * 4)
     {
-      if (warn_disabled_optimization)
-	warning (0, "%s: %d basic blocks and %d edges/basic block",
-		 pass, n_basic_blocks, n_edges / n_basic_blocks);
+      warning (OPT_Wdisabled_optimization,
+	       "%s: %d basic blocks and %d edges/basic block",
+	       pass, n_basic_blocks, n_edges / n_basic_blocks);
 
       return true;
     }
@@ -6542,9 +6542,9 @@ is_too_expensive (const char *pass)
        * SBITMAP_SET_SIZE (max_reg_num ())
        * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY)
     {
-      if (warn_disabled_optimization)
-	warning (0, "%s: %d basic blocks and %d registers",
-		 pass, n_basic_blocks, max_reg_num ());
+      warning (OPT_Wdisabled_optimization,
+	       "%s: %d basic blocks and %d registers",
+	       pass, n_basic_blocks, max_reg_num ());
 
       return true;
     }
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.108
diff -p -U3 -r1.108  opts.c
--- opts.c	16 May 2005 12:30:04 -0000	1.108
+++ opts.c	19 May 2005 02:01:34 -0000
@@ -668,7 +668,8 @@ decode_options (unsigned int argc, const
 	 this to `2' if -Wall is used, so we can avoid giving out
 	 lots of errors for people who don't realize what -Wall does.  */
       if (warn_uninitialized == 1)
-	warning (0, "-Wuninitialized is not supported without -O");
+	warning (OPT_Wuninitialized,
+		 "-Wuninitialized is not supported without -O");
     }
 
   if (flag_really_no_inline == 2)
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.231
diff -p -U3 -r1.231  stor-layout.c
--- stor-layout.c	11 May 2005 12:24:43 -0000	1.231
+++ stor-layout.c	19 May 2005 02:01:34 -0000
@@ -869,8 +869,7 @@ place_field (record_layout_info rli, tre
       /* No, we need to skip space before this field.
 	 Bump the cumulative size to multiple of field alignment.  */
 
-      if (warn_padded)
-	warning (0, "%Jpadding struct to align %qD", field, field);
+      warning (OPT_Wpadded, "%Jpadding struct to align %qD", field, field);
 
       /* If the alignment is still within offset_align, just align
 	 the bit position.  */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.954
diff -p -U3 -r1.954  toplev.c
--- toplev.c	3 May 2005 17:55:38 -0000	1.954
+++ toplev.c	19 May 2005 02:01:34 -0000
@@ -403,11 +403,6 @@ static const struct
 target_options[] = TARGET_OPTIONS;
 #endif
 
-/* Nonzero means warn about function definitions that default the return type
-   or that use a null return and have a return-type other than void.  */
-
-int warn_return_type;
-
 /* Output files for assembler code (real compiler output)
    and debugging dumps.  */
 
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.194
diff -p -U3 -r2.194  tree-cfg.c
--- tree-cfg.c	19 May 2005 01:05:06 -0000	2.194
+++ tree-cfg.c	19 May 2005 02:01:34 -0000
@@ -2102,11 +2102,11 @@ remove_bb (basic_block bb)
      loop above, so the last statement we process is the first statement
      in the block.  */
 #ifdef USE_MAPPED_LOCATION
-  if (warn_notreached && loc > BUILTINS_LOCATION)
-    warning (0, "%Hwill never be executed", &loc);
+  if (loc > BUILTINS_LOCATION)
+    warning (OPT_Wunreachable_code, "%Hwill never be executed", &loc);
 #else
-  if (warn_notreached && loc)
-    warning (0, "%Hwill never be executed", loc);
+  if (loc)
+    warning (OPT_Wunreachable_code, "%Hwill never be executed", loc);
 #endif
 
   remove_phi_nodes_and_edges_for_unreachable_block (bb);


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