diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-23 14:55:55 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-23 14:55:55 +0000 |
commit | 6adc88f8cafa463569e6ee3dacd9b7e0a40051c1 (patch) | |
tree | 61e5b420fe39332b5b0cad26106b740dd349a4fa /libcpp | |
parent | 51ad98633c056041b60df3f980a412b47e20acc3 (diff) | |
download | gcc-6adc88f8cafa463569e6ee3dacd9b7e0a40051c1.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192715 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 17 | ||||
-rw-r--r-- | libcpp/files.c | 44 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 3 | ||||
-rw-r--r-- | libcpp/init.c | 4 | ||||
-rw-r--r-- | libcpp/internal.h | 4 |
5 files changed, 60 insertions, 12 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index fdc151c9aa6..9b833522836 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,20 @@ +2012-10-23 Joseph Myers <joseph@codesourcery.com> + + * 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. + 2012-10-15 Tobias Burnus <burnus@net-b.de> * files.c (read_file_guts, _cpp_save_file_entries): Free memory diff --git a/libcpp/files.c b/libcpp/files.c index 6fc24e2af44..ecaa27414e1 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -110,6 +110,9 @@ struct _cpp_file /* If BUFFER above contains the true contents of the file. */ bool buffer_valid; + + /* If this file is implicitly preincluded. */ + bool implicit_preinclude; }; /* A singly-linked list for all searches for a given file name, with @@ -291,7 +294,8 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) /* If the file is not included as first include from either the toplevel file or the command-line it is not a valid use of PCH. */ if (pfile->all_files - && pfile->all_files->next_file) + && pfile->all_files->next_file + && !pfile->all_files->next_file->implicit_preinclude) return false; flen = strlen (path); @@ -480,9 +484,14 @@ _cpp_find_failed (_cpp_file *file) descriptor. FD can be -1 if the file was found in the cache and had previously been closed. To open it again pass the return value to open_file(). + + If IMPLICIT_PREINCLUDE then it is OK for the file to be missing. + If present, it is OK for a precompiled header to be included after + it. */ _cpp_file * -_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool fake, int angle_brackets) +_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, + bool fake, int angle_brackets, bool implicit_preinclude) { struct file_hash_entry *entry, **hash_slot; _cpp_file *file; @@ -506,6 +515,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f return entry->u.file; file = make_cpp_file (pfile, start_dir, fname); + file->implicit_preinclude = implicit_preinclude; /* Try each path in the include chain. */ for (; !fake ;) @@ -535,7 +545,14 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f cpp_error (pfile, CPP_DL_ERROR, "use -Winvalid-pch for more information"); } - open_file_failed (pfile, file, angle_brackets); + if (implicit_preinclude) + { + free ((char *) file->name); + free (file); + return NULL; + } + else + open_file_failed (pfile, file, angle_brackets); break; } @@ -950,7 +967,10 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, if (!dir) return false; - file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); + file = _cpp_find_file (pfile, fname, dir, false, angle_brackets, + type == IT_DEFAULT); + if (type == IT_DEFAULT && file == NULL) + return false; /* Compensate for the increment in linemap_add that occurs in _cpp_stack_file. In the case of a normal #include, we're @@ -960,7 +980,8 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, This does not apply if we found a PCH file (in which case linemap_add is not called) or we were included from the command-line. */ - if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE) + if (file->pchname == NULL && file->err_no == 0 + && type != IT_CMDLINE && type != IT_DEFAULT) pfile->line_table->highest_location--; return _cpp_stack_file (pfile, file, type == IT_IMPORT); @@ -1243,7 +1264,7 @@ cpp_clear_file_cache (cpp_reader *pfile) void _cpp_fake_include (cpp_reader *pfile, const char *fname) { - _cpp_find_file (pfile, fname, pfile->buffer->file->dir, true, 0); + _cpp_find_file (pfile, fname, pfile->buffer->file->dir, true, 0, false); } /* Not everyone who wants to set system-header-ness on a buffer can @@ -1361,7 +1382,7 @@ _cpp_compare_file_date (cpp_reader *pfile, const char *fname, if (!dir) return -1; - file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); + file = _cpp_find_file (pfile, fname, dir, false, angle_brackets, false); if (file->err_no) return -1; @@ -1382,6 +1403,15 @@ cpp_push_include (cpp_reader *pfile, const char *fname) return _cpp_stack_include (pfile, fname, false, IT_CMDLINE); } +/* Pushes the given file, implicitly included at the start of a + compilation, onto the buffer stack but without any errors if the + file is not found. Returns nonzero if successful. */ +bool +cpp_push_default_include (cpp_reader *pfile, const char *fname) +{ + return _cpp_stack_include (pfile, fname, true, IT_DEFAULT); +} + /* Do appropriate cleanup when a file INC's buffer is popped off the input stack. */ void diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 2ec7eaaae2f..a58454e9839 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -1,6 +1,6 @@ /* Definitions for CPP library. Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2007, 2008, 2009, 2010, 2011 + 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Per Bothner, 1994-95. @@ -1010,6 +1010,7 @@ extern bool cpp_included (cpp_reader *, const char *); extern bool cpp_included_before (cpp_reader *, const char *, source_location); extern void cpp_make_system_header (cpp_reader *, int, int); extern bool cpp_push_include (cpp_reader *, const char *); +extern bool cpp_push_default_include (cpp_reader *, const char *); extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *); extern const char *cpp_get_path (struct _cpp_file *); extern cpp_dir *cpp_get_dir (struct _cpp_file *); diff --git a/libcpp/init.c b/libcpp/init.c index 040ab34eb90..81b66df57e5 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -1,7 +1,7 @@ /* CPP Library. Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, - 2009, 2010, 2011 Free Software Foundation, Inc. + 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Per Bothner, 1994-95. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -593,7 +593,7 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname) } pfile->main_file - = _cpp_find_file (pfile, fname, &pfile->no_search_path, false, 0); + = _cpp_find_file (pfile, fname, &pfile->no_search_path, false, 0, false); if (_cpp_find_failed (pfile->main_file)) return NULL; diff --git a/libcpp/internal.h b/libcpp/internal.h index 79dd54f06cf..312b8b5cb0e 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -117,7 +117,7 @@ extern unsigned char *_cpp_unaligned_alloc (cpp_reader *, size_t); #define BUFF_LIMIT(BUFF) ((BUFF)->limit) /* #include types. */ -enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE}; +enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE, IT_DEFAULT}; union utoken { @@ -625,7 +625,7 @@ extern void _cpp_destroy_hashtable (cpp_reader *); /* In files.c */ typedef struct _cpp_file _cpp_file; extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *, - bool, int); + bool, int, bool); extern bool _cpp_find_failed (_cpp_file *); extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *); extern void _cpp_fake_include (cpp_reader *, const char *); |