diff options
author | obrien <obrien@FreeBSD.org> | 2002-05-14 01:44:02 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-05-14 01:44:02 +0000 |
commit | 7d64ac0ab2fed32992a1776e2875c7c9d5682ba5 (patch) | |
tree | e697d756e4e19d8fb99cd7446340ffb275e00988 /contrib/gcc/c-decl.c | |
parent | ac911779196855de86565ccf576a2aeeab54f5dd (diff) | |
download | FreeBSD-src-7d64ac0ab2fed32992a1776e2875c7c9d5682ba5.zip FreeBSD-src-7d64ac0ab2fed32992a1776e2875c7c9d5682ba5.tar.gz |
If you want to not warn on K&R main(); this is how it should be implemented.
Diffstat (limited to 'contrib/gcc/c-decl.c')
-rw-r--r-- | contrib/gcc/c-decl.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/contrib/gcc/c-decl.c b/contrib/gcc/c-decl.c index 46685e2..e6a2293 100644 --- a/contrib/gcc/c-decl.c +++ b/contrib/gcc/c-decl.c @@ -379,6 +379,11 @@ int warn_traditional; int warn_pointer_arith; + +/* Nonzero means do not warn that K&R style main() is not a function prototype. */ + +int flag_bsd_no_warn_kr_main; + /* Nonzero means warn for non-prototype function decls or non-prototyped defs without previous prototype. */ @@ -531,6 +536,7 @@ c_decode_option (argc, argv) flag_noniso_default_format_attributes = 0; flag_isoc99 = 0; flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; } else if (!strcmp (argstart, "iso9899:199409")) { @@ -550,6 +556,7 @@ c_decode_option (argc, argv) flag_isoc99 = 1; flag_isoc94 = 1; flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; } else if (!strcmp (argstart, "gnu89")) { @@ -561,6 +568,7 @@ c_decode_option (argc, argv) flag_isoc99 = 0; flag_isoc94 = 0; flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; } else if (!strcmp (argstart, "gnu9x") || !strcmp (argstart, "gnu99")) { @@ -572,6 +580,7 @@ c_decode_option (argc, argv) flag_isoc99 = 1; flag_isoc94 = 1; flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; } else if (!strcmp (argstart, "bsd")) { @@ -584,6 +593,7 @@ c_decode_option (argc, argv) flag_isoc94 = 0; flag_isoc94 = 0; flag_bsd_format = 1; + flag_bsd_no_warn_kr_main = 1; } else error ("unknown C standard `%s'", argstart); @@ -6313,7 +6323,9 @@ start_function (declspecs, declarator, attributes) && !(old_decl != 0 && (TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0 || (DECL_BUILT_IN (old_decl) - && ! C_DECL_ANTICIPATED (old_decl))))) + && ! C_DECL_ANTICIPATED (old_decl)))) + && !(flag_bsd_no_warn_kr_main && 0 == + strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))) warning ("function declaration isn't a prototype"); /* Optionally warn of any global def with no previous prototype. */ else if (warn_missing_prototypes |