aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-04-06 07:31:44 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1994-04-06 07:31:44 -0400
commit1474fe46658b9f862fea62b270754bd5a3eb243c (patch)
tree434770c36939635a3a719d72eb063b9d683d5846 /gcc
parent812fe08e5a54874b5265b504787afcb79d02769d (diff)
downloadgcc-1474fe46658b9f862fea62b270754bd5a3eb243c.zip
gcc-1474fe46658b9f862fea62b270754bd5a3eb243c.tar.gz
gcc-1474fe46658b9f862fea62b270754bd5a3eb243c.tar.bz2
(warn_missing_declarations): New variable.
(c_decode_option): -Wmissing-declarations. (start_function): Actually do the checking. From-SVN: r6981
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-decl.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 13b51f9..53b08ee 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -484,6 +484,11 @@ int warn_strict_prototypes;
int warn_missing_prototypes;
+/* Nonzero means warn for any global function def
+ without separate previous decl. */
+
+int warn_missing_declarations;
+
/* Nonzero means warn about multiple (redundant) decls for the same single
variable or function. */
@@ -627,6 +632,10 @@ c_decode_option (p)
warn_missing_prototypes = 1;
else if (!strcmp (p, "-Wno-missing-prototypes"))
warn_missing_prototypes = 0;
+ else if (!strcmp (p, "-Wmissing-declarations"))
+ warn_missing_declarations = 1;
+ else if (!strcmp (p, "-Wno-missing-declarations"))
+ warn_missing_declarations = 0;
else if (!strcmp (p, "-Wredundant-decls"))
warn_redundant_decls = 1;
else if (!strcmp (p, "-Wno-redundant-decls"))
@@ -5832,7 +5841,20 @@ start_function (declspecs, declarator, nested)
else if (warn_missing_prototypes
&& old_decl != 0 && TREE_USED (old_decl)
&& !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
- warning_with_decl (decl1, "`%s' was used with no prototype before its definition");
+ warning_with_decl (decl1,
+ "`%s' was used with no prototype before its definition");
+ /* Optionally warn of any global def with no previous declaration. */
+ else if (warn_missing_declarations
+ && TREE_PUBLIC (decl1)
+ && old_decl == 0
+ && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))
+ warning_with_decl (decl1, "no previous declaration for `%s'");
+ /* Optionally warn of any def with no previous declaration
+ if the function has already been used. */
+ else if (warn_missing_declarations
+ && old_decl != 0 && TREE_USED (old_decl))
+ warning_with_decl (decl1,
+ "`%s' was used with no declaration before its definition");
/* This is a definition, not a reference.
So normally clear DECL_EXTERNAL.