This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: "format not a string literal"
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: "format not a string literal"
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 22 Nov 1999 23:37:55 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <199910261734.NAA05739@caip.rutgers.edu>you write:
> On a related note, I also submitted a two part patch to fix the
> legitimate cases Ken's new warning exposes. I installed the Java dir
> stuff cause apbianco looked at those, but the remaining ones await
> approval. (I would appreciate a second pair of eyes taking a look at
> these changes.)
>
> http://egcs.cygnus.com/ml/gcc-patches/1999-10/msg00271.html
Mostly OK.
c-decl.c:
@@ -5352,9 +5358,8 @@ finish_struct (t, fieldlist, attributes)
break;
if (x == 0)
- pedwarn ((fieldlist
- ? "%s has no named members"
- : "%s has no members"),
+ pedwarn ("%s has no %smembers",
+ fieldlist ? "named " : "",
TREE_CODE (t) == UNION_TYPE ? "union" : "struct");
}
This looks wrong. Shouldn't the 2nd & 3rd arguments be in the opposite order
from what you did?
> http://egcs.cygnus.com/ml/gcc-patches/1999-10/msg00272.html
Mostly OK too.
In cp/decl.c, you've got code like
diff -rup orig/egcs-CVS19991010/gcc/cp/decl.c egcs-CVS19991010/gcc/cp/decl.c
--- orig/egcs-CVS19991010/gcc/cp/decl.c Sat Oct 9 17:06:03 1999
+++ egcs-CVS19991010/gcc/cp/decl.c Sun Oct 10 23:39:34 1999
@@ -4020,22 +4020,21 @@ pushdecl (x)
/* No shadow warnings for vars made for inlining. */
&& ! DECL_FROM_INLINE (x))
{
- const char *warnstring = NULL;
-
if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
- warnstring = "declaration of `%s' shadows a parameter";
+ warning("declaration of `%s' shadows a parameter",
+ IDENTIFIER_POINTER (name));
else if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE
&& current_class_ptr
&& !TREE_STATIC (name))
- warnstring = "declaration of `%s' shadows a member of `this'";
+ warning("declaration of `%s' shadows a member of `this'",
+ IDENTIFIER_POINTER (name));
else if (oldlocal != NULL_TREE)
- warnstring = "declaration of `%s' shadows previous local";
+ warning("declaration of `%s' shadows previous local",
+ IDENTIFIER_POINTER (name));
else if (oldglobal != NULL_TREE)
/* XXX shadow warnings in outer-more namespaces */
- warnstring = "declaration of `%s' shadows global declaration";
-
- if (warnstring)
- warning (warnstring, IDENTIFIER_POINTER (name));
+ warning("declaration of `%s' shadows global declaration",
+ IDENTIFIER_POINTER (name));
}
}
You need a space between "warning" and the open paren.
Otherwise both patches are fine. Feel free to install them after fixing
the minor problems noted above.
jeff