diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-06-06 08:11:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-06-06 08:11:02 +0000 |
commit | 417ce1d6136867633eed5393d82661978ad576cd (patch) | |
tree | d011315a251d74b992cd891536a8e9baad95d066 /gnu/gcc | |
parent | f8c24e237ffa166068cdb7d02dd888d0e5c11b1d (diff) |
prevent segfault on amd64 when -Wmissing-include-dirs -I/nonexistent
(happens even with empty files), as diagnosed with kili@ on
evolution-database.
We obviously need to check the token chain and go up if we're at the start
of a buffer (unless we're really at the start unless we have to give up).
Independent fix. Same functionality as code found on the gcc 4.5 branch,
but completely different lines.
okay miod@
Diffstat (limited to 'gnu/gcc')
-rw-r--r-- | gnu/gcc/libcpp/errors.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gnu/gcc/libcpp/errors.c b/gnu/gcc/libcpp/errors.c index 97de4900001..c8efd538796 100644 --- a/gnu/gcc/libcpp/errors.c +++ b/gnu/gcc/libcpp/errors.c @@ -153,7 +153,20 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) } else { - src_loc = pfile->cur_token[-1].src_loc; + /* Find actual previous token. */ + cpp_token *t; + + if (pfile->cur_token != pfile->cur_run->base) + t = pfile->cur_token - 1; + else + { + if (pfile->cur_run->prev != NULL) + t = pfile->cur_run->prev->limit; + else + t = NULL; + } + /* Retrieve corresponding source location, unless we failed. */ + src_loc = t ? t->src_loc : 0; } if (_cpp_begin_message (pfile, level, src_loc, 0)) |