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][RFA] PR35652: suppress multiple warnings


This is a tiny patch that ameliorates the worst excesses of the problem
described in gcc PR35652, based on the suggestion by Richard Guenther.

It's not a complete fix, but does improve the situation considerably by
removing the duplication of warnings with the example program in the PR,
and printing only the first.  (A full and complete fix may be hard,
invasive, and potentially not worthwhile.)

Regression tested on i686 Linux for gcc and g++.  Okay?


:ADDPATCH diagnostic:

gcc/ChangeLog
2008-04-25  Simon Baldwin <simonb@google.com>

	PR c/35652
	* builtins.c (c_strlen): Suppressed multiple warnings that can occur
	with propagated string constants.


Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 134680)
+++ gcc/builtins.c	(working copy)
@@ -447,7 +447,12 @@
      runtime.  */
   if (offset < 0 || offset > max)
     {
-      warning (0, "offset outside bounds of constant string");
+     /* Suppress multiple warnings for propagated constant strings.  */
+      if (! TREE_NO_WARNING (src))
+        {
+          warning (0, "offset outside bounds of constant string");
+          TREE_NO_WARNING (src) = 1;
+        }
       return NULL_TREE;
     }
 


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