diff options
author | Dodji Seketeli <dodji@gcc.gnu.org> | 2014-01-28 16:03:19 +0100 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2014-01-28 16:03:19 +0100 |
commit | 367c82866e7c439004f283bb45fdbe09479c0d7f (patch) | |
tree | fbc9e0ef5ef690d21749ed8b474f18cbf615fb05 /gcc/input.c | |
parent | 07ec81f958b765032f234d08623b9a23c374a09e (diff) | |
download | gcc-367c82866e7c439004f283bb45fdbe09479c0d7f.zip gcc-367c82866e7c439004f283bb45fdbe09479c0d7f.tar.gz gcc-367c82866e7c439004f283bb45fdbe09479c0d7f.tar.bz2 |
PR preprocessor/59935 - caret diagnostics crashes on non-file locations
gcc/ChangeLog
* input.c (location_get_source_line): Bail out on when line number
is zero, and test the return value of
lookup_or_add_file_to_cache_tab.
gcc/testsuite/ChangeLog
* c-c++-common/cpp/warning-zero-location.c: New test.
* c-c++-common/cpp/warning-zero-location-2.c: Likewise.
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
From-SVN: r207195
Diffstat (limited to 'gcc/input.c')
-rw-r--r-- | gcc/input.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/input.c b/gcc/input.c index 547c177..63cd062 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -698,7 +698,13 @@ location_get_source_line (expanded_location xloc, static char *buffer; static ssize_t len; - fcache * c = lookup_or_add_file_to_cache_tab (xloc.file); + if (xloc.line == 0) + return NULL; + + fcache *c = lookup_or_add_file_to_cache_tab (xloc.file); + if (c == NULL) + return NULL; + bool read = read_line_num (c, xloc.line, &buffer, &len); if (read && line_len) |