From 49da480ff6208abc419fe66e030dfa052c11ee1b Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Mon, 22 Jan 2018 14:31:10 +0000 Subject: [PATCH] Fix the RX assembler so that it can handle escaped double quote characters, ie: \" PR 22737 * config/tc-rx.c (rx_start_line): Handle escaped double-quote character. * testsuite/gas/rx/pr22737.s: New test. * testsuite/gas/rx/pr22737.d: Likewise. * testsuite/gas/rx/rx.exp: Run the new test. --- gas/ChangeLog | 8 ++++++++ gas/config/tc-rx.c | 7 +++++-- gas/testsuite/gas/rx/pr22737.d | 15 +++++++++++++++ gas/testsuite/gas/rx/pr22737.s | 1 + gas/testsuite/gas/rx/rx.exp | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gas/testsuite/gas/rx/pr22737.d create mode 100644 gas/testsuite/gas/rx/pr22737.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 001d30dec47..7e81c3eaebe 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2018-01-22 Oleg Endo + + PR 22737 + * config/tc-rx.c (rx_start_line): Handle escaped double-quote character. + * testsuite/gas/rx/pr22737.s: New test. + * testsuite/gas/rx/pr22737.d: Likewise. + * testsuite/gas/rx/rx.exp: Run the new test. + 2018-01-19 Thomas Preud'homme * config/tc-arm.c (ToC macro): Remove spurious comment. diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c index 8e49ddd5274..6c8befe5eae 100644 --- a/gas/config/tc-rx.c +++ b/gas/config/tc-rx.c @@ -2681,6 +2681,7 @@ rx_start_line (void) int in_single_quote = 0; int done = 0; char * p = input_line_pointer; + char prev_char = 0; /* Scan the line looking for question marks. Skip past quote enclosed regions. */ do @@ -2693,7 +2694,9 @@ rx_start_line (void) break; case '"': - in_double_quote = ! in_double_quote; + /* Handle escaped double quote \" inside a string. */ + if (prev_char != '\\') + in_double_quote = ! in_double_quote; break; case '\'': @@ -2722,7 +2725,7 @@ rx_start_line (void) break; } - p ++; + prev_char = *p++; } while (! done); } diff --git a/gas/testsuite/gas/rx/pr22737.d b/gas/testsuite/gas/rx/pr22737.d new file mode 100644 index 00000000000..370540855a8 --- /dev/null +++ b/gas/testsuite/gas/rx/pr22737.d @@ -0,0 +1,15 @@ +#objdump: -dr + +dump.o: file format elf32-rx-le + + +Disassembly of section .*: + +00000000 <.*>: + 0: ff 16.* + 2: c8 1f 68 22.* + 6: d0 64.* + 8: a0 3f.* + a: 3a e1 4f.* + d: da 0e 8c b6 c6 9c.* +.* diff --git a/gas/testsuite/gas/rx/pr22737.s b/gas/testsuite/gas/rx/pr22737.s new file mode 100644 index 00000000000..74b29f0fbc6 --- /dev/null +++ b/gas/testsuite/gas/rx/pr22737.s @@ -0,0 +1 @@ +.ascii "\377\026\310\037h\"\320d\240?:\341O\332\016\214\266\306\234." diff --git a/gas/testsuite/gas/rx/rx.exp b/gas/testsuite/gas/rx/rx.exp index d8cca78f983..e6d21dda89d 100644 --- a/gas/testsuite/gas/rx/rx.exp +++ b/gas/testsuite/gas/rx/rx.exp @@ -35,3 +35,4 @@ foreach test [lsort [glob $srcdir/$subdir/*.sm]] { run_dump_test "rx-asm-good" # run_list_test "rx-asm-bad" "" "Generation of error messages with bogus Renesas assembler directives" run_dump_test "pr19665" +run_dump_test "pr22737" -- 2.30.2