This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to warn about non-static declaration follows static one
- To: egcs-patches at cygnus dot com
- Subject: Patch to warn about non-static declaration follows static one
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Thu, 22 Oct 1998 15:17:01 -0400 (EDT)
Although it is perhaps legal, a non-static decl following a
static one isn't portable. So I thought I'd make gcc warn about it like
it already does for the opposite type of mismatch.
Okay to install?
--Kaveh
Thu Oct 22 15:10:13 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-decl.c (duplicate_decls): Also warn if first declaration is
static and second one isn't.
--- egcs-CVS19981021/gcc/c-decl.c~ Wed Oct 21 16:06:06 1998
+++ egcs-CVS19981021/gcc/c-decl.c Thu Oct 22 15:05:19 1998
@@ -1812,6 +1812,13 @@ duplicate_decls (newdecl, olddecl, diffe
&& !TREE_PUBLIC (newdecl))
warning_with_decl (newdecl, "static declaration for `%s' follows non-static");
+ /* If pedantic, warn when non-static declaration follows a static
+ declaration. Otherwise, do so only for functions. */
+ if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL)
+ && !TREE_PUBLIC (olddecl)
+ && TREE_PUBLIC (newdecl))
+ warning_with_decl (newdecl, "non-static declaration for `%s' follows static");
+
/* Warn when const declaration follows a non-const
declaration, but not for functions. */
if (TREE_CODE (olddecl) != FUNCTION_DECL
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Icon CMT Corp.