Message ID | 1481566454-12915-1-git-send-email-dmalcolm@redhat.com |
---|---|
State | New |
Headers | show |
This crashes the compiler on ia64. FAIL: c-c++-common/raw-string-6.c -Wc++-compat (test for excess errors) Excess errors: /usr/local/gcc/gcc-20161214/gcc/testsuite/c-c++-common/raw-string-6.c:5:1: internal compiler error: Segmentation fault 0x400000000108571f crash_signal ../../gcc/toplev.c:333 0x4000000002024dcf _cpp_process_line_notes ../../libcpp/lex.c:1108 0x400000000202b5af _cpp_lex_direct ../../libcpp/lex.c:3097 0x400000000202f0ff _cpp_lex_token ../../libcpp/lex.c:2554 0x400000000204169f cpp_get_token_1 ../../libcpp/macro.c:2462 0x40000000004252af c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int) ../../gcc/c-family/c-lex.c:398 0x40000000002e4eaf c_lex_one_token ../../gcc/c/c-parser.c:244 0x40000000003404ff c_parser_peek_token(c_parser*) ../../gcc/c/c-parser.c:431 0x40000000003404ff c_parser_declaration_or_fndef ../../gcc/c/c-parser.c:1907 0x40000000003574ef c_parser_external_declaration ../../gcc/c/c-parser.c:1463 0x400000000035905f c_parser_translation_unit ../../gcc/c/c-parser.c:1343 0x400000000035905f c_parse_file() ../../gcc/c/c-parser.c:18140 0x400000000043e5ef c_common_parse_file() ../../gcc/c-family/c-opts.c:1098 Andreas.
On Wed, Dec 14, 2016 at 11:54:21AM +0100, Andreas Schwab wrote: > This crashes the compiler on ia64. > > FAIL: c-c++-common/raw-string-6.c -Wc++-compat (test for excess errors) > Excess errors: > /usr/local/gcc/gcc-20161214/gcc/testsuite/c-c++-common/raw-string-6.c:5:1: internal compiler error: Segmentation fault > 0x400000000108571f crash_signal > ../../gcc/toplev.c:333 > 0x4000000002024dcf _cpp_process_line_notes > ../../libcpp/lex.c:1108 > 0x400000000202b5af _cpp_lex_direct > ../../libcpp/lex.c:3097 > 0x400000000202f0ff _cpp_lex_token > ../../libcpp/lex.c:2554 > 0x400000000204169f cpp_get_token_1 > ../../libcpp/macro.c:2462 > 0x40000000004252af c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int) > ../../gcc/c-family/c-lex.c:398 > 0x40000000002e4eaf c_lex_one_token > ../../gcc/c/c-parser.c:244 > 0x40000000003404ff c_parser_peek_token(c_parser*) > ../../gcc/c/c-parser.c:431 > 0x40000000003404ff c_parser_declaration_or_fndef > ../../gcc/c/c-parser.c:1907 > 0x40000000003574ef c_parser_external_declaration > ../../gcc/c/c-parser.c:1463 > 0x400000000035905f c_parser_translation_unit > ../../gcc/c/c-parser.c:1343 > 0x400000000035905f c_parse_file() > ../../gcc/c/c-parser.c:18140 > 0x400000000043e5ef c_common_parse_file() > ../../gcc/c-family/c-opts.c:1098 I'm seeing the same failure, with the same backtrace on aarch64*-none-elf and arm*-none-eabi targets when this test is run with a c++ compiler. Thanks, James
On Wed, 2016-12-14 at 11:54 +0100, Andreas Schwab wrote: > This crashes the compiler on ia64. Sorry about the breakage. I'm able to reproduce this under valgrind on x86_64 (looks like a read after free); I'm working on a fix. Thanks Dave > FAIL: c-c++-common/raw-string-6.c -Wc++-compat (test for excess > errors) > Excess errors: > /usr/local/gcc/gcc-20161214/gcc/testsuite/c-c++-common/raw-string > -6.c:5:1: internal compiler error: Segmentation fault > 0x400000000108571f crash_signal > ../../gcc/toplev.c:333 > 0x4000000002024dcf _cpp_process_line_notes > ../../libcpp/lex.c:1108 > 0x400000000202b5af _cpp_lex_direct > ../../libcpp/lex.c:3097 > 0x400000000202f0ff _cpp_lex_token > ../../libcpp/lex.c:2554 > 0x400000000204169f cpp_get_token_1 > ../../libcpp/macro.c:2462 > 0x40000000004252af c_lex_with_flags(tree_node**, unsigned int*, > unsigned char*, int) > ../../gcc/c-family/c-lex.c:398 > 0x40000000002e4eaf c_lex_one_token > ../../gcc/c/c-parser.c:244 > 0x40000000003404ff c_parser_peek_token(c_parser*) > ../../gcc/c/c-parser.c:431 > 0x40000000003404ff c_parser_declaration_or_fndef > ../../gcc/c/c-parser.c:1907 > 0x40000000003574ef c_parser_external_declaration > ../../gcc/c/c-parser.c:1463 > 0x400000000035905f c_parser_translation_unit > ../../gcc/c/c-parser.c:1343 > 0x400000000035905f c_parse_file() > ../../gcc/c/c-parser.c:18140 > 0x400000000043e5ef c_common_parse_file() > ../../gcc/c-family/c-opts.c:1098 > > Andreas. >
diff --git a/gcc/testsuite/gcc.dg/format/pr78680.c b/gcc/testsuite/gcc.dg/format/pr78680.c new file mode 100644 index 0000000..0c599f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/pr78680.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wextra -fdiagnostics-show-caret" } */ + +void fn1() { + __builtin_printf("\ + %ld.\n\ + 2\n"); }; +/* { dg-warning "expects a matching" "" { target *-*-* } .-3 } */ +/* { dg-begin-multiline-output "" } + __builtin_printf("\ + ^~ + %ld.\n\ + ~~~~~~~ + 2\n"); }; + ~~~~ + { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c index 9372936..afbe0f7 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-1.c @@ -689,3 +689,22 @@ void test_multiple_ordinary_maps (void) ~~ { dg-end-multiline-output "" } */ } + +/* Verify that we correctly handle a token that spans multiple + physical lines. */ + +const char *test_multiline_token (void) +{ + __emit_expression_range (0, "foo\ +bar\ +baz"); +/* { dg-warning "range" "" { target *-*-* } .-3 } */ +/* { dg-begin-multiline-output "" } + __emit_expression_range (0, "foo\ + ^~~~~ + bar\ + ~~~~ + baz"); + ~~~~ + { dg-end-multiline-output "" } */ +} diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c index 76a085e..03f042a 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c @@ -272,3 +272,23 @@ test_terminator_location (void) ^ { dg-end-multiline-output "" } */ } + +/* Verify that we fail gracefully when a string literal token is split + across multiple physical lines. */ + +void +test_backslash_continued_logical_lines (void) +{ + __emit_string_literal_range ("\ +01234\ +56789", 6, 6, 7); + /* { dg-error "unable to read substring location: range endpoints are on different lines" "" { target *-*-* } .-3 } */ + /* { dg-begin-multiline-output "" } + __emit_string_literal_range ("\ + ^~ + 01234\ + ~~~~~~ + 56789", 6, 6, 7); + ~~~~~~ + { dg-end-multiline-output "" } */ +} diff --git a/libcpp/lex.c b/libcpp/lex.c index cea8848..ae45892 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -3089,6 +3089,13 @@ _cpp_lex_direct (cpp_reader *pfile) break; } + /* Ensure that any line notes are processed, so that we have the + correct physical line/column for the end-point of the token even + when a logical line is split via one or more backslashes. */ + if (buffer->cur >= buffer->notes[buffer->cur_note].pos + && !pfile->overlaid_buffer) + _cpp_process_line_notes (pfile, false); + source_range tok_range; tok_range.m_start = result->src_loc; if (result->src_loc >= RESERVED_LOCATION_COUNT)