From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 240653857022; Fri, 26 Jul 2024 06:01:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 240653857022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1721973688; bh=UxTozDcnz6R1LAPeIyttE+r681Mtx7IhR826pATHmXg=; h=From:To:Subject:Date:From; b=LRbgrF8b52CQWEuJ2Jzaf7fvFYNjrsNc5YwI75Zfe5EYkvkDSchNFoTYgE33UuwfA bAvO3O5q1k2QnJgBLydCFwFE+WvQsi34IaLr+ZIcYeePUjrpxamBSoU1CxefvZ1uaM ajUJoQaeyGTTV8aBhJjGpgEKxTOOIo4GN29Qsjqk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: binutils-cvs@sourceware.org Subject: [binutils-gdb] gas: drop scrubber state -2 X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: c97f0d71ea9cc5c3bf63aacef34b5ebc95dd3b9a X-Git-Newrev: e0b9535c824deb24e209acddcb7662124aeb413f Message-Id: <20240726060128.240653857022@sourceware.org> Date: Fri, 26 Jul 2024 06:01:28 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De0b9535c824d= eb24e209acddcb7662124aeb413f commit e0b9535c824deb24e209acddcb7662124aeb413f Author: Jan Beulich Date: Fri Jul 26 08:00:42 2024 +0200 gas: drop scrubber state -2 =20 Instead re-use code handling LEX_IS_TWOCHAR_COMMENT_1ST, thus ensuring that we wouldn't get bogus state transitions: For example, when we're in states 0 or 1, a comment should be no different from whitespace encountered in those states. Plus for e.g. x86 this results in such comments now truly being converted to a blank, as mandated by documentation. Both aspects apparently were a result of blindly (and wrongly) moving to state 3 _before_ consuming the "ungot" blank. =20 Also amend a related comment elsewhere. =20 In the new testcase the .irp is to make visible in the listing all the whitespace that the scrubber inserts / leaves in place. Diff: --- gas/app.c | 54 +++++------------------------------= ---- gas/testsuite/gas/i386/comments.l | 30 ++++++++++++++++++++++ gas/testsuite/gas/i386/comments.s | 13 ++++++++++ gas/testsuite/gas/i386/i386.exp | 1 + 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/gas/app.c b/gas/app.c index 6a3efb1f687..fa877851f01 100644 --- a/gas/app.c +++ b/gas/app.c @@ -217,7 +217,8 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_UNUSED) lex[(unsigned char) *p] =3D LEX_IS_PARALLEL_SEPARATOR; #endif =20 - /* Only allow slash-star comments if slash is not in use. + /* Only allow slash-star comments if slash is not in use. Certain + other cases are dealt with in LEX_IS_LINE_COMMENT_START handling. FIXME: This isn't right. We should always permit them. */ if (lex['/'] =3D=3D 0) lex['/'] =3D LEX_IS_TWOCHAR_COMMENT_1ST; @@ -476,7 +477,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *t= ostart, size_t tolen, 10: After seeing whitespace in state 9 (keep white before symchar) 11: After seeing a symbol character in state 0 (eg a label definition) -1: output string in out_string and go to the state in old_state - -2: flush text until a '*' '/' is seen, then go to state old_state 12: no longer used #ifdef DOUBLEBAR_PARALLEL 13: After seeing a vertical bar, looking for a second @@ -579,43 +579,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *= tostart, size_t tolen, PUT (ch); continue; =20 - case -2: - for (;;) - { - do - { - ch =3D GET (); - - if (ch =3D=3D EOF) - { - as_warn (_("end of file in comment")); - goto fromeof; - } - - if (ch =3D=3D '\n') - PUT ('\n'); - } - while (ch !=3D '*'); - - while ((ch =3D GET ()) =3D=3D '*') - ; - - if (ch =3D=3D EOF) - { - as_warn (_("end of file in comment")); - goto fromeof; - } - - if (ch =3D=3D '/') - break; - - UNGET (ch); - } - - state =3D old_state; - UNGET (' '); - continue; - case 4: ch =3D GET (); if (ch =3D=3D EOF) @@ -1076,6 +1039,7 @@ do_scrub_chars (size_t (*get) (char *, size_t), char = *tostart, size_t tolen, ch2 =3D GET (); if (ch2 =3D=3D '*') { + twochar_comment: for (;;) { do @@ -1290,15 +1254,9 @@ do_scrub_chars (size_t (*get) (char *, size_t), char= *tostart, size_t tolen, { ch2 =3D GET (); if (ch2 =3D=3D '*') - { - old_state =3D 3; - state =3D -2; - break; - } - else if (ch2 !=3D EOF) - { - UNGET (ch2); - } + goto twochar_comment; + if (ch2 !=3D EOF) + UNGET (ch2); } =20 if (state =3D=3D 0 || state =3D=3D 1) /* Only comment at start of line.= */ diff --git a/gas/testsuite/gas/i386/comments.l b/gas/testsuite/gas/i386/com= ments.l new file mode 100644 index 00000000000..7aef3a13f22 --- /dev/null +++ b/gas/testsuite/gas/i386/comments.l @@ -0,0 +1,30 @@ +.*: Assembler messages: +.*:6: Error: .* +.*:7: Error: .* +[ ]*[0-9]+[ ]+scrubber: +[ ]*[0-9]+[ ]+\.irp x,"" +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+/\* \*/vaddps %zmm0, %zmm1, %zmm2 +[ ]*[0-9]+[ ]+vaddps/\*\*/%zmm0, %zmm1, %zmm2 +[ ]*[0-9]+[ ]+vadd/\*\*/ps %zmm0, %zmm1, %zmm2 +[ ]*[0-9]+[ ]+vaddps %zmm/\*\*/0, %zmm1, %zmm2 +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+vaddps %zmm0, %zmm1, %zmm2# ... +[ ]*[0-9]+[ ]+vaddps %zmm0, %zmm1, %zmm2 # ... +[ ]*[0-9]+[ ]+vaddps %zmm0, %zmm1, %zmm2/\* \*/# ... +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+\.endr +[ ]*[0-9]+[ ]+> + +[ ]*[0-9]+ \?\?\?\? [0-9A-F]+[ ]+> vaddps %zmm0,%zmm1,%zmm2 +#... +[ ]*[0-9]+ \?\?\?\? [0-9A-F]+[ ]+> vaddps %zmm0,%zmm1,%zmm2 +#... +[ ]*[0-9]+[ ]+> vadd ps %zmm0,%zmm1,%zmm2 +[ ]*[0-9]+[ ]+> vaddps %zmm 0,%zmm1,%zmm2 +[ ]*[0-9]+[ ]+> + +[ ]*[0-9]+ \?\?\?\? [0-9A-F]+[ ]+> vaddps %zmm0,%zmm1,%zmm2 +#... +[ ]*[0-9]+ \?\?\?\? [0-9A-F]+[ ]+> vaddps %zmm0,%zmm1,%zmm2 +#... +[ ]*[0-9]+ \?\?\?\? [0-9A-F]+[ ]+> vaddps %zmm0,%zmm1,%zmm2 +#pass diff --git a/gas/testsuite/gas/i386/comments.s b/gas/testsuite/gas/i386/com= ments.s new file mode 100644 index 00000000000..ea700eb733a --- /dev/null +++ b/gas/testsuite/gas/i386/comments.s @@ -0,0 +1,13 @@ +scrubber: + .irp x,"" + +/* */vaddps %zmm0, %zmm1, %zmm2 + vaddps/**/%zmm0, %zmm1, %zmm2 + vadd/**/ps %zmm0, %zmm1, %zmm2 + vaddps %zmm/**/0, %zmm1, %zmm2 + + vaddps %zmm0, %zmm1, %zmm2# ... + vaddps %zmm0, %zmm1, %zmm2 # ... + vaddps %zmm0, %zmm1, %zmm2/* */# ... + + .endr diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.= exp index bf9cb2637bd..590a55d0c81 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -105,6 +105,7 @@ if [gas_32_check] then { run_dump_test "equ" run_list_test "equ-2" "-al" run_list_test "equ-bad" + run_list_test "comments" "-almn" run_dump_test "curly" run_dump_test "separator" run_dump_test "divide"