From 007aaed01eca764360469e510f0398825332fa5c Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 12 Apr 1999 14:05:29 +0000 Subject: [PATCH] c-decl.c (c_decode_option, [...]): Recognize -Wno-main so we can avoid warnings. * c-decl.c (c_decode_option, start_decl, start_function, finish_function) : Recognize -Wno-main so we can avoid warnings. From-SVN: r26376 --- gcc/ChangeLog | 5 +++++ gcc/c-decl.c | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 148fb5772ef..9ac08aae141 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Fri Apr 12 15:00:52 1999 Stan Cox + + * c-decl.c (c_decode_option, start_decl, start_function, + finish_function) : Recognize -Wno-main so we can avoid warnings. + 1999-04-12 14:55 -0400 Zack Weinberg * cpphash.c (collect_expansion, macroexpand, diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 5f9d2faf29c..a232217bc0a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -855,7 +855,7 @@ c_decode_option (argc, argv) else if (!strcmp (p, "-Wmain")) warn_main = 1; else if (!strcmp (p, "-Wno-main")) - warn_main = 0; + warn_main = -1; else if (!strcmp (p, "-Wsign-compare")) warn_sign_compare = 1; else if (!strcmp (p, "-Wno-sign-compare")) @@ -3791,7 +3791,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) /* The corresponding pop_obstacks is in finish_decl. */ push_obstacks_nochange (); - if (warn_main && TREE_CODE (decl) != FUNCTION_DECL + if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL && !strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "main")) warning_with_decl (decl, "`%s' is usually a function"); @@ -6527,7 +6527,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes, nested) TREE_PUBLIC (decl1) = 0; /* Warn for unlikely, improbable, or stupid declarations of `main'. */ - if (warn_main + if (warn_main > 0 && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))) == 0) { tree args; @@ -7244,12 +7244,8 @@ finish_function (nested) if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) != integer_type_node) { - /* You would expect the sense of this test to be the other way - around, but if warn_main is set, we will already have warned, - so this would be a duplicate. This is the warning you get - in some environments even if you *don't* ask for it, because - these are environments where it may be more of a problem than - usual. */ + /* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned. + If warn_main is -1 (-Wno-main) we don't want to be warned. */ if (! warn_main) pedwarn_with_decl (fndecl, "return type of `%s' is not `int'"); } -- 2.30.2