]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Fix \+ expansion for .irp and .irpc
authorFangrui Song <maskray@gcc.gnu.org>
Wed, 15 May 2024 22:05:30 +0000 (15:05 -0700)
committerFangrui Song <maskray@gcc.gnu.org>
Wed, 15 May 2024 22:05:30 +0000 (15:05 -0700)
.irp and .irpc receive a null macro_entry.  \+ causes a crash after the
recent \+ support.  Restore the previous behavior.

Signed-off-by: Fangrui Song <maskray@gcc.gnu.org>
gas/macro.c
gas/testsuite/gas/macros/count.l
gas/testsuite/gas/macros/count.s

index 72d869d317fd6f9f687acc0501914dddb0c3c222..3036e6a58669dadf9c149cbb4c2e5023d129daa9 100644 (file)
@@ -854,7 +854,7 @@ macro_expand_body (sb *in, sb *out, formal_entry *formals,
              sprintf (buffer, "%u", macro_number);
              sb_add_string (out, buffer);
            }
-         else if (src < in->len && in->ptr[src] == '+')
+         else if (macro && src < in->len && in->ptr[src] == '+')
            {
              /* Sub in the current macro invocation number.  */
 
index 3418b0bab006bf6bfb588c00543638069a05a6d7..ca666ea019516e7c458d08b4bc6f3b59ad697535 100644 (file)
@@ -8,3 +8,5 @@
 1
 4
 2
+\+
+\+
index c752ca8367d3856e553ce35b5d94499205cf591e..4a5b078ba6081d4c9a49ef7648b229045408ce18 100644 (file)
 
        mac1 2
        mac2 3
+
+       .irp i,1
+       .print "\+"
+       .endr
+       .irpc i,1
+       .print "\+"
+       .endr