diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2014-09-30 16:08:53 +0000 |
---|---|---|
committer | Bernd Edlinger <edlinger@gcc.gnu.org> | 2014-09-30 16:08:53 +0000 |
commit | cc811a8ae6c760955ac2dca51d8359d003c8e4f2 (patch) | |
tree | ab32b139b652fc4cee08f6e47ca2d986547e773f | |
parent | cd91371c5f1ed77c2acdde60f194a98df95c241b (diff) | |
download | gcc-cc811a8ae6c760955ac2dca51d8359d003c8e4f2.zip gcc-cc811a8ae6c760955ac2dca51d8359d003c8e4f2.tar.gz gcc-cc811a8ae6c760955ac2dca51d8359d003c8e4f2.tar.bz2 |
re PR preprocessor/58893 (<command-line>:0:0: internal compiler error: Segmentation fault)
2014-09-30 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR preprocessor/58893
* errors.c (cpp_diagnostic): Fix possible out of bounds access.
* files.c (_cpp_stack_include): Initialize src_loc for IT_CMDLINE.
testsuite:
2014-09-30 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR preprocessor/58893
* gcc.dg/pr58893.c: New test case.
* gcc.dg/pr58893-0.h: New include.
From-SVN: r215730
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr58893-0.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr58893.c | 5 | ||||
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/errors.c | 5 | ||||
-rw-r--r-- | libcpp/files.c | 12 |
6 files changed, 31 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 858df23..6ffbbee 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-09-30 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR preprocessor/58893 + * gcc.dg/pr58893.c: New test case. + * gcc.dg/pr58893-0.h: New include. + 2014-09-30 Ilya Tocar <ilya.tocar@intel.com> PR middle-end/62120 diff --git a/gcc/testsuite/gcc.dg/pr58893-0.h b/gcc/testsuite/gcc.dg/pr58893-0.h new file mode 100644 index 0000000..957bcdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr58893-0.h @@ -0,0 +1 @@ +#pragma GCC visibility push(hidden) diff --git a/gcc/testsuite/gcc.dg/pr58893.c b/gcc/testsuite/gcc.dg/pr58893.c new file mode 100644 index 0000000..c9f8b6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr58893.c @@ -0,0 +1,5 @@ +/* PR preprocessor/58893 */ +/* { dg-do compile } */ +/* { dg-options "-include pr58893-0.h -include pr58893-1.h -I${srcdir}/gcc.dg" } */ +/* { dg-error "pr58893-1.h: No such file or directory" "" { target *-*-* } 0 } */ +/* { dg-prune-output "compilation terminated" } */ diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 463bb60..9299904 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-30 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR preprocessor/58893 + * errors.c (cpp_diagnostic): Fix possible out of bounds access. + * files.c (_cpp_stack_include): Initialize src_loc for IT_CMDLINE. + 2014-09-24 Marek Polacek <polacek@redhat.com> PR c/61405 diff --git a/libcpp/errors.c b/libcpp/errors.c index d1ca7a1..bc857f0 100644 --- a/libcpp/errors.c +++ b/libcpp/errors.c @@ -48,10 +48,7 @@ cpp_diagnostic (cpp_reader * pfile, int level, int reason, current run -- that is invalid. */ else if (pfile->cur_token == pfile->cur_run->base) { - if (pfile->cur_run->prev != NULL) - src_loc = pfile->cur_run->prev->limit->src_loc; - else - src_loc = 0; + src_loc = 0; } else { diff --git a/libcpp/files.c b/libcpp/files.c index a442783..00302fd 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -991,6 +991,18 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, _cpp_file *file; bool stacked; + /* For -include command-line flags we have type == IT_CMDLINE. + When the first -include file is processed we have the case, where + pfile->cur_token == pfile->cur_run->base, we are directly called up + by the front end. However in the case of the second -include file, + we are called from _cpp_lex_token -> _cpp_get_fresh_line -> + cpp_push_include, with pfile->cur_token != pfile->cur_run->base, + and pfile->cur_token[-1].src_loc not (yet) initialized. + However, when the include file cannot be found, we need src_loc to + be initialized to some safe value: 0 means UNKNOWN_LOCATION. */ + if (type == IT_CMDLINE && pfile->cur_token != pfile->cur_run->base) + pfile->cur_token[-1].src_loc = 0; + dir = search_path_head (pfile, fname, angle_brackets, type); if (!dir) return false; |