summaryrefslogtreecommitdiffstats
path: root/gnu/gcc/libcpp/errors.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2010-06-06 08:11:01 +0000
committerespie <espie@openbsd.org>2010-06-06 08:11:01 +0000
commitb57625335ca463b1eec7041fa42ca5717b0b693a (patch)
treee0b892a4f904c4fbd6f6b445c4bb7233a2b44545 /gnu/gcc/libcpp/errors.c
parentoops, make sure we have wpa before using it. (diff)
downloadwireguard-openbsd-b57625335ca463b1eec7041fa42ca5717b0b693a.tar.xz
wireguard-openbsd-b57625335ca463b1eec7041fa42ca5717b0b693a.zip
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/libcpp/errors.c')
-rw-r--r--gnu/gcc/libcpp/errors.c15
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))