diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-01-31 09:31:52 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-01-31 09:31:52 +0100 |
commit | 1306a81d81747ccc36f3ca53af74a3d069fafb7d (patch) | |
tree | 2b05a215f7e85a7a5f2b75c760f521ae28a5992d /libcpp | |
parent | 7b56ebc34708f685bd5cf47763d13614c7e707e1 (diff) | |
download | gcc-1306a81d81747ccc36f3ca53af74a3d069fafb7d.zip gcc-1306a81d81747ccc36f3ca53af74a3d069fafb7d.tar.gz gcc-1306a81d81747ccc36f3ca53af74a3d069fafb7d.tar.bz2 |
re PR preprocessor/69869 (internal compiler error: Segmentation fault in call to skip_macro_block_comment when using '-traditional-cpp')
PR preprocessor/69869
* traditional.c (skip_macro_block_comment): Return bool, true if
the macro block comment is unterminated.
(copy_comment): Use return value from skip_macro_block_comment instead
of always false.
* gcc.dg/cpp/trad/pr69869.c: New test.
From-SVN: r257220
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 8 | ||||
-rw-r--r-- | libcpp/traditional.c | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index fdddd93..9c675a5 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2018-01-31 Jakub Jelinek <jakub@redhat.com> + + PR preprocessor/69869 + * traditional.c (skip_macro_block_comment): Return bool, true if + the macro block comment is unterminated. + (copy_comment): Use return value from skip_macro_block_comment instead + of always false. + 2018-01-27 Jakub Jelinek <jakub@redhat.com> * include/cpplib.h (enum cpp_builtin_type): Change BT_LAST_USER from diff --git a/libcpp/traditional.c b/libcpp/traditional.c index e07c96b..b25d522 100644 --- a/libcpp/traditional.c +++ b/libcpp/traditional.c @@ -119,8 +119,11 @@ check_output_buffer (cpp_reader *pfile, size_t n) } /* Skip a C-style block comment in a macro as a result of -CC. - Buffer->cur points to the initial asterisk of the comment. */ -static void + PFILE->buffer->cur points to the initial asterisk of the comment, + change it to point to after the '*' and '/' characters that terminate it. + Return true if the macro has not been termined, in that case set + PFILE->buffer->cur to the end of the buffer. */ +static bool skip_macro_block_comment (cpp_reader *pfile) { const uchar *cur = pfile->buffer->cur; @@ -131,10 +134,15 @@ skip_macro_block_comment (cpp_reader *pfile) /* People like decorating comments with '*', so check for '/' instead for efficiency. */ - while(! (*cur++ == '/' && cur[-2] == '*') ) - ; + while (! (*cur++ == '/' && cur[-2] == '*')) + if (cur[-1] == '\n') + { + pfile->buffer->cur = cur - 1; + return true; + } pfile->buffer->cur = cur; + return false; } /* CUR points to the asterisk introducing a comment in the current @@ -158,7 +166,7 @@ copy_comment (cpp_reader *pfile, const uchar *cur, int in_define) buffer->cur = cur; if (pfile->context->prev) - unterminated = false, skip_macro_block_comment (pfile); + unterminated = skip_macro_block_comment (pfile); else unterminated = _cpp_skip_block_comment (pfile); |