diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 31 | ||||
-rwxr-xr-x | libcpp/configure | 1 | ||||
-rw-r--r-- | libcpp/configure.ac | 1 | ||||
-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 |
7 files changed, 76 insertions, 12 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index fdc151c9aa6..4bd0b26aa5e 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,34 @@ +2012-10-23 Ian Bolton <ian.bolton@arm.com> + Jim MacArthur <jim.macarthur@arm.com> + Marcus Shawcroft <marcus.shawcroft@arm.com> + Nigel Stephens <nigel.stephens@arm.com> + Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> + Richard Earnshaw <rearnsha@arm.com> + Sofiane Naci <sofiane.naci@arm.com> + Stephen Thomas <stephen.thomas@arm.com> + Tejas Belagod <tejas.belagod@arm.com> + Yufeng Zhang <yufeng.zhang@arm.com> + + * configure.ac: Enable AArch64. + * configure: Regenerate. + +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/configure b/libcpp/configure index 01e4462307f..d33969b2b2d 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -7096,6 +7096,7 @@ fi case $target in + aarch64*-*-* | \ alpha*-*-* | \ arm*-*-*eabi* | \ arm*-*-symbianelf* | \ diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 29bd8c5e6f1..e62da06ce27 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -134,6 +134,7 @@ fi m4_changequote(,) case $target in + aarch64*-*-* | \ alpha*-*-* | \ arm*-*-*eabi* | \ arm*-*-symbianelf* | \ 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 *); |