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]

[PATCH] Fix C++ -Wno-div-by-zero


Hi, 

this is a simple cleanup which also makes -Wno-div-by-zero work for C++. The 
documentation already stated that it would work that way, while it actually 
didn't. 


2006-01-31  Dirk Mueller  <dmueller@suse.com>
	
	* c.opt: Remove Var(warn_div_by_zero).
	* c-opts.c: Remove dead OPT_Wdiv_by_zero case.

	* typeck.c: Annotate division by zero warnings so
	that -Wno-div-by-zero works correctly.


Index: c-opts.c
===================================================================
--- c-opts.c	(revision 110395)
+++ c-opts.c	(working copy)
@@ -431,10 +431,6 @@ c_common_handle_option (size_t scode, co
       cpp_opts->warn_deprecated = value;
       break;
 
-    case OPT_Wdiv_by_zero:
-      warn_div_by_zero = value;
-      break;
-
     case OPT_Wendif_labels:
       cpp_opts->warn_endif_labels = value;
       break;
Index: c.opt
===================================================================
--- c.opt	(revision 110395)
+++ c.opt	(working copy)
@@ -166,7 +166,7 @@ C++ ObjC++ Var(warn_deprecated) Init(1)
 Warn about deprecated compiler features
 
 Wdiv-by-zero
-C ObjC Var(warn_div_by_zero) Init(1)
+C ObjC C++ Init(1)
 Warn about compile-time integer division by zero
 
 Weffc++
--- cp/typeck.c	(revision 110395)
+++ cp/typeck.c	(working copy)
@@ -2954,9 +2954,9 @@ build_binary_op (enum tree_code code, tr
 	      || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
 	{
 	  if (TREE_CODE (op1) == INTEGER_CST && integer_zerop (op1))
-	    warning (0, "division by zero in %<%E / 0%>", op0);
+	    warning (OPT_Wdiv_by_zero, "division by zero in %<%E / 0%>", op0);
 	  else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1))
-	    warning (0, "division by zero in %<%E / 0.%>", op0);
+	    warning (OPT_Wdiv_by_zero, "division by zero in %<%E / 0.%>", op0);
 
 	  if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
 	    code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
@@ -2991,9 +2991,9 @@ build_binary_op (enum tree_code code, tr
     case TRUNC_MOD_EXPR:
     case FLOOR_MOD_EXPR:
       if (code1 == INTEGER_TYPE && integer_zerop (op1))
-	warning (0, "division by zero in %<%E %% 0%>", op0);
+	warning (OPT_Wdiv_by_zero, "division by zero in %<%E %% 0%>", op0);
       else if (code1 == REAL_TYPE && real_zerop (op1))
-	warning (0, "division by zero in %<%E %% 0.%>", op0);
+	warning (OPT_Wdiv_by_zero, "division by zero in %<%E %% 0.%>", op0);
 
       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
 	{




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