diff options
Diffstat (limited to 'contrib/gcc/c-decl.c')
| -rw-r--r-- | contrib/gcc/c-decl.c | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/contrib/gcc/c-decl.c b/contrib/gcc/c-decl.c index 2c8857fc4964..5cd13d253fab 100644 --- a/contrib/gcc/c-decl.c +++ b/contrib/gcc/c-decl.c @@ -19,6 +19,8 @@ along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* Process declarations and symbol lookup for C front end. Also constructs types; the standard scalar types at initialization, and structure, union, array and enum types when they are declared. */ @@ -312,6 +314,10 @@ int flag_isoc94 = 0; int flag_isoc99 = 0; +/* Nonzero means allow the BSD kernel printf enhancments. */ + +int flag_bsd_format = 0; + /* Nonzero means that we have builtin functions, and main is an int */ int flag_hosted = 1; @@ -373,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. */ @@ -508,6 +519,7 @@ c_decode_option (argc, argv) -std=c99 same as -std=iso9899:1999 -std=gnu89 default, iso9899:1990 + gnu extensions -std=gnu99 iso9899:1999 + gnu extensions + -std=bsd iso9899:1999 + BSD kernel printf extensions */ const char *const argstart = &p[5]; @@ -523,6 +535,8 @@ c_decode_option (argc, argv) flag_no_nonansi_builtin = 1; 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")) { @@ -541,6 +555,8 @@ c_decode_option (argc, argv) flag_noniso_default_format_attributes = 0; flag_isoc99 = 1; flag_isoc94 = 1; + flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; } else if (!strcmp (argstart, "gnu89")) { @@ -551,6 +567,8 @@ c_decode_option (argc, argv) flag_noniso_default_format_attributes = 1; 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")) { @@ -561,6 +579,21 @@ c_decode_option (argc, argv) flag_noniso_default_format_attributes = 1; flag_isoc99 = 1; flag_isoc94 = 1; + flag_bsd_format = 0; + flag_bsd_no_warn_kr_main = 0; + } + else if (!strcmp (argstart, "bsd")) + { + flag_traditional = 0; + flag_writable_strings = 0; + flag_no_asm = 0; + flag_no_nonansi_builtin = 0; + flag_noniso_default_format_attributes = 1; + flag_isoc99 = 0; + flag_isoc94 = 0; + flag_isoc94 = 0; + flag_bsd_format = 1; + flag_bsd_no_warn_kr_main = 1; } else error ("unknown C standard `%s'", argstart); @@ -1997,10 +2030,9 @@ duplicate_decls (newdecl, olddecl, different_binding_level) inline, make sure we emit debug info for the inline before we throw it away, in case it was inlined into a function that hasn't been written out yet. */ - if (new_is_definition && DECL_INITIAL (olddecl)) + if (new_is_definition && DECL_INITIAL (olddecl) && TREE_USED (olddecl)) { - if (TREE_USED (olddecl)) - (*debug_hooks->outlining_inline_function) (olddecl); + (*debug_hooks->outlining_inline_function) (olddecl); /* The new defn must not be inline. */ DECL_INLINE (newdecl) = 0; @@ -3098,6 +3130,55 @@ c_init_decl_processing () = build_function_type (ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, endlink)); + /* Types which are common to the fortran compiler and libf2c. When + changing these, you also need to be concerned with f/com.h. */ + + if (TYPE_PRECISION (float_type_node) + == TYPE_PRECISION (long_integer_type_node)) + { + g77_integer_type_node = long_integer_type_node; + g77_uinteger_type_node = long_unsigned_type_node; + } + else if (TYPE_PRECISION (float_type_node) + == TYPE_PRECISION (integer_type_node)) + { + g77_integer_type_node = integer_type_node; + g77_uinteger_type_node = unsigned_type_node; + } + else + g77_integer_type_node = g77_uinteger_type_node = NULL_TREE; + + if (g77_integer_type_node != NULL_TREE) + { + pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_integer"), + g77_integer_type_node)); + pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_uinteger"), + g77_uinteger_type_node)); + } + + if (TYPE_PRECISION (float_type_node) * 2 + == TYPE_PRECISION (long_integer_type_node)) + { + g77_longint_type_node = long_integer_type_node; + g77_ulongint_type_node = long_unsigned_type_node; + } + else if (TYPE_PRECISION (float_type_node) * 2 + == TYPE_PRECISION (long_long_integer_type_node)) + { + g77_longint_type_node = long_long_integer_type_node; + g77_ulongint_type_node = long_long_unsigned_type_node; + } + else + g77_longint_type_node = g77_ulongint_type_node = NULL_TREE; + + if (g77_longint_type_node != NULL_TREE) + { + pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_longint"), + g77_longint_type_node)); + pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_ulongint"), + g77_ulongint_type_node)); + } + pedantic_lvalues = pedantic; make_fname_decl = c_make_fname_decl; @@ -6237,7 +6318,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 |
