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]

Patch to warn about non-static declaration follows static one


	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.


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