diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-10-23 15:55:55 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2012-10-23 15:55:55 +0100 |
commit | 1efcb8c6f6c9a8f70c90159c363f30657710e941 (patch) | |
tree | 61e5b420fe39332b5b0cad26106b740dd349a4fa /gcc/c-family | |
parent | 3b601ca3eb1cb588cc0383c9480eb6fcb986ea2d (diff) | |
download | gcc-1efcb8c6f6c9a8f70c90159c363f30657710e941.zip gcc-1efcb8c6f6c9a8f70c90159c363f30657710e941.tar.gz gcc-1efcb8c6f6c9a8f70c90159c363f30657710e941.tar.bz2 |
gcc:
* config.gcc (*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu |
*-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu): Use
glibc-c.o in c_target_objs and cxx_target_objs. Use t-glibc in
tmake_file. Set target_has_targetcm.
(tilegx-*-linux*, tilepro-*-linux*): Append to c_target_objs and
cxx_target_objs rather than overriding previous value.
* config/glibc-c.c, config/t-glibc: New.
* doc/tm.texi.in (TARGET_C_PREINCLUDE): New @hook.
* doc/tm.texi: Regenerate.
* hooks.c (hook_constcharptr_void_null): New.
* hooks.h (hook_constcharptr_void_null): Declare.
gcc/c-family:
* c-common.h (pch_cpp_save_state): Declare.
* c-target.def (c_preinclude): New hook.
* c-opts.c (done_preinclude): New.
(push_command_line_include): Handle default preincluded header.
(cb_file_change): Call pch_cpp_save_state when calling
push_command_line_include.
* c-pch.c (pch_ready_to_save_cpp_state, pch_cpp_state_saved)
(pch_cpp_save_state): New.
(pch_init): Call pch_cpp_save_state conditionally, instead of
calling cpp_save_state.
gcc/testsuite:
* gcc.dg/c99-predef-1.c: New test.
* gcc.dg/cpp/cmdlne-dU-1.c, gcc.dg/cpp/cmdlne-dU-2.c,
gcc.dg/cpp/cmdlne-dU-3.c, gcc.dg/cpp/cmdlne-dU-4.c,
gcc.dg/cpp/cmdlne-dU-5.c, gcc.dg/cpp/cmdlne-dU-6.c,
gcc.dg/cpp/cmdlne-dU-7.c, gcc.dg/cpp/cmdlne-dU-8.c,
gcc.dg/cpp/cmdlne-dU-9.c, gcc.dg/cpp/cmdlne-dU-10.c,
gcc.dg/cpp/cmdlne-dU-11.c, gcc.dg/cpp/cmdlne-dU-12.c,
gcc.dg/cpp/cmdlne-dU-13.c, gcc.dg/cpp/cmdlne-dU-14.c,
gcc.dg/cpp/cmdlne-dU-15.c, gcc.dg/cpp/cmdlne-dU-16.c,
gcc.dg/cpp/cmdlne-dU-17.c, gcc.dg/cpp/cmdlne-dU-18.c,
gcc.dg/cpp/cmdlne-dU-19.c, gcc.dg/cpp/cmdlne-dU-20.c,
gcc.dg/cpp/cmdlne-dU-21.c, gcc.dg/cpp/cmdlne-dU-22.c,
gcc.dg/cpp/mi5.c, gcc.dg/cpp/multiline.c: Add -nostdinc to
dg-options.
libcpp:
* files.c (struct _cpp_file): Add implicit_preinclude.
(pch_open_file): Allow a previously opened implicitly included
file.
(_cpp_find_file): Add implicit_preinclude argument. Free file and
do not call open_file_failed if implicit_preinclude. Store
implicit_preinclude value.
(_cpp_stack_include, _cpp_fake_include, _cpp_compare_file_date):
Update calls to _cpp_find_file.
(_cpp_stack_include): Handle IT_DEFAULT.
(cpp_push_default_include): New.
* include/cpplib.h (cpp_push_default_include): Declare.
* init.c (cpp_read_main_file): Update call to _cpp_find_file.
* internal.h (enum include_type): Add IT_DEFAULT.
(_cpp_find_file): Update prototype.
From-SVN: r192715
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 21 | ||||
-rw-r--r-- | gcc/c-family/c-pch.c | 30 | ||||
-rw-r--r-- | gcc/c-family/c-target.def | 17 |
5 files changed, 79 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3fb6a30..cf43137 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2012-10-23 Joseph Myers <joseph@codesourcery.com> + + * c-common.h (pch_cpp_save_state): Declare. + * c-target.def (c_preinclude): New hook. + * c-opts.c (done_preinclude): New. + (push_command_line_include): Handle default preincluded header. + (cb_file_change): Call pch_cpp_save_state when calling + push_command_line_include. + * c-pch.c (pch_ready_to_save_cpp_state, pch_cpp_state_saved) + (pch_cpp_save_state): New. + (pch_init): Call pch_cpp_save_state conditionally, instead of + calling cpp_save_state. + 2012-10-20 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/53063 diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 94449a5..c78804d 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1021,6 +1021,7 @@ extern tree c_build_bind_expr (location_t, tree, tree); /* In c-pch.c */ extern void pch_init (void); +extern void pch_cpp_save_state (void); extern int c_common_valid_pch (cpp_reader *pfile, const char *name, int fd); extern void c_common_read_pch (cpp_reader *pfile, const char *name, int fd, const char *orig); diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index b1746d0..b420d2a 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -108,6 +108,9 @@ static size_t deferred_count; /* Number of deferred options scanned for -include. */ static size_t include_cursor; +/* Whether any standard preincluded header has been preincluded. */ +static bool done_preinclude; + static void handle_OPT_d (const char *); static void set_std_cxx98 (int); static void set_std_cxx11 (int); @@ -1353,6 +1356,19 @@ c_finish_options (void) static void push_command_line_include (void) { + if (!done_preinclude) + { + done_preinclude = true; + if (flag_hosted && std_inc && !cpp_opts->preprocessed) + { + const char *preinc = targetcm.c_preinclude (); + if (preinc && cpp_push_default_include (parse_in, preinc)) + return; + } + } + + pch_cpp_save_state (); + while (include_cursor < deferred_count) { struct deferred_opt *opt = &deferred_opts[include_cursor++]; @@ -1388,7 +1404,10 @@ cb_file_change (cpp_reader * ARG_UNUSED (pfile), fe_file_change (new_map); if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map))) - push_command_line_include (); + { + pch_cpp_save_state (); + push_command_line_include (); + } } void diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index b239ed4..f945f05 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -93,6 +93,10 @@ get_ident (void) return result; } +/* Whether preprocessor state should be saved by pch_init. */ + +static bool pch_ready_to_save_cpp_state = false; + /* Prepare to write a PCH file, if one is being written. This is called at the start of compilation. */ @@ -136,7 +140,31 @@ pch_init (void) /* Let the debugging format deal with the PCHness. */ (*debug_hooks->handle_pch) (0); - cpp_save_state (parse_in, f); + if (pch_ready_to_save_cpp_state) + pch_cpp_save_state (); +} + +/* Whether preprocessor state has been saved in a PCH file. */ + +static bool pch_cpp_state_saved = false; + +/* Save preprocessor state in a PCH file, after implicitly included + headers have been read. If the PCH file has not yet been opened, + record that state should be saved when it is opened. */ + +void +pch_cpp_save_state (void) +{ + if (!pch_cpp_state_saved) + { + if (pch_outfile) + { + cpp_save_state (parse_in, pch_outfile); + pch_cpp_state_saved = true; + } + else + pch_ready_to_save_cpp_state = true; + } } /* Write the PCH file. This is called at the end of a compilation which diff --git a/gcc/c-family/c-target.def b/gcc/c-family/c-target.def index c5ebdf1..c2025ab 100644 --- a/gcc/c-family/c-target.def +++ b/gcc/c-family/c-target.def @@ -1,6 +1,6 @@ /* Target hook definitions for C-family front ends. Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, - 2011 + 2011, 2012 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -89,5 +89,20 @@ DEFHOOK @var{format_arg} is one recognized as a valid string reference type.", void, (tree format_arg, tree args_list), NULL) + +DEFHOOK +(c_preinclude, + "Define this hook to return the name of a header file to be included at\ + the start of all compilations, as if it had been included with\ + @code{#include <@var{file}>}. If this hook returns @code{NULL}, or is\ + not defined, or the header is not found, or if the user specifies\ + @option{-ffreestanding} or @option{-nostdinc}, no header is included.\n\ +\n\ + This hook can be used together with a header provided by the system C\ + library to implement ISO C requirements for certain macros to be\ + predefined that describe properties of the whole implementation rather\ + than just the compiler.", + const char *, (void), + hook_constcharptr_void_null) HOOK_VECTOR_END (C90_EMPTY_HACK) |