diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-07-19 11:54:09 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-07-19 11:54:09 +0200 |
commit | 0d96d156aca0aa022f174be4add3d3cb56d7f6b7 (patch) | |
tree | ea3e58d79d83bd525bcb964bda2e900a1614d92f | |
parent | da0fa10a4e0967be13cfa86a64a992602161b31d (diff) | |
download | binutils-0d96d156aca0aa022f174be4add3d3cb56d7f6b7.zip binutils-0d96d156aca0aa022f174be4add3d3cb56d7f6b7.tar.gz binutils-0d96d156aca0aa022f174be4add3d3cb56d7f6b7.tar.bz2 |
gas: consistently drop trailing whitespace when scrubbing
From especially the checks for the two separator forms it appears to
follow that the construct being touched is about trailing whitespace. In
such a case, considering that for many targets ordinary and line comment
chars overlap, take into account that line comment chars override
ordinary ones in lex[] (logic elsewhere in do_scrub_chars() actually
depends on that ordering, and also accounts for this overriding).
Plus of course IS_NEWLINE() would better also be consulted. Note also
that the DOUBLESLASH_LINE_COMMENTS change should generally have no
effect just yet; it's a prereq for a later change but better fits here.
Leave respective comments as well, and update documentation to correct
which comment form is actually replaced by a single blank (i.e. neither
the ones starting with what {,tc_}comment_chars[] has nor the ones
starting with what line_comment_chars[] has).
-rw-r--r-- | gas/app.c | 19 | ||||
-rw-r--r-- | gas/doc/as.texi | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-insn-e.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l | 4 |
8 files changed, 34 insertions, 15 deletions
@@ -87,6 +87,7 @@ static char last_char; #define IS_PARALLEL_SEPARATOR(c) (lex[c] == LEX_IS_PARALLEL_SEPARATOR) #define IS_COMMENT(c) (lex[c] == LEX_IS_COMMENT_START) #define IS_LINE_COMMENT(c) (lex[c] == LEX_IS_LINE_COMMENT_START) +#define IS_TWOCHAR_COMMENT_1ST(c) (lex[c] == LEX_IS_TWOCHAR_COMMENT_1ST) #define IS_NEWLINE(c) (lex[c] == LEX_IS_NEWLINE) static char lex[256] = { @@ -197,6 +198,9 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_UNUSED) for (p = tc_comment_chars; *p; p++) lex[(unsigned char) *p] = LEX_IS_COMMENT_START; + /* While counter intuitive to have more special purpose line comment chars + override more general purpose ordinary ones, logic in do_scrub_chars() + depends on this ordering. */ for (p = line_comment_chars; *p; p++) lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START; @@ -962,7 +966,12 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, } } #endif + + /* Prune trailing whitespace. */ if (IS_COMMENT (ch) + || (IS_LINE_COMMENT (ch) + && (state < 1 || strchr (tc_comment_chars, ch))) + || IS_NEWLINE (ch) || IS_LINE_SEPARATOR (ch) || IS_PARALLEL_SEPARATOR (ch)) { @@ -975,6 +984,16 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, } goto recycle; } +#ifdef DOUBLESLASH_LINE_COMMENTS + if (IS_TWOCHAR_COMMENT_1ST (ch)) + { + ch2 = GET (); + if (ch2 != EOF) + UNGET (ch2); + if (ch2 == '/') + goto recycle; + } +#endif /* If we're in state 2 or 11, we've seen a non-white character followed by whitespace. If the next character diff --git a/gas/doc/as.texi b/gas/doc/as.texi index b2a3f24..3501744 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -2990,11 +2990,11 @@ as exactly one space. @section Comments @cindex comments -There are two ways of rendering comments to @command{@value{AS}}. In both -cases the comment is equivalent to one space. +There are two ways of rendering comments to @command{@value{AS}}. Anything from @samp{/*} through the next @samp{*/} is a comment. -This means you may not nest these comments. +This means you may not nest these comments. Such a comment is equivalent to +one space, plus bumping the line counter accordingly. @smallexample /* diff --git a/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l index d0a305d..45b31d6 100644 --- a/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l @@ -25,7 +25,7 @@ .*:50: Warning: extended operand requested but not required .*:51: Error: opcode not supported on this processor: mips1 \(mips1\) `restore\.e 128' .*:52: Error: opcode not supported on this processor: mips1 \(mips1\) `save\.e 128' -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -71,7 +71,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips1 \(mips1\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' diff --git a/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l index 62f3979..97f3c49 100644 --- a/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l @@ -25,7 +25,7 @@ .*:50: Warning: extended operand requested but not required .*:51: Error: opcode not supported on this processor: mips3 \(mips3\) `restore\.e 128' .*:52: Error: opcode not supported on this processor: mips3 \(mips3\) `save\.e 128' -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -71,7 +71,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Warning: extended operand requested but not required -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' diff --git a/gas/testsuite/gas/mips/mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-insn-e.l index 0527389..32aa003 100644 --- a/gas/testsuite/gas/mips/mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Warning: extended operand requested but not required -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' diff --git a/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l index 4ec4797..a66cc35 100644 --- a/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips32 \(mips32\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' diff --git a/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l index 474110c..095e0b0 100644 --- a/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips32r2 \(mips32r2\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' diff --git a/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l index 3fd6457..a0c55df 100644 --- a/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: interaptiv-mr2 \(mips32r3\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' |