[PATCH] gas: Fix \+ expansion for .irp and .irpc
Fangrui Song
maskray@google.com
Wed May 15 07:04:02 GMT 2024
From: Fangrui Song <maskray@gcc.gnu.org>
.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 | 2 +-
gas/testsuite/gas/macros/count.l | 2 ++
gas/testsuite/gas/macros/count.s | 4 ++++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gas/macro.c b/gas/macro.c
index 72d869d317f..483b1b51449 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -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 (src < in->len && in->ptr[src] == '+' && macro)
{
/* Sub in the current macro invocation number. */
diff --git a/gas/testsuite/gas/macros/count.l b/gas/testsuite/gas/macros/count.l
index 3418b0bab00..ca666ea0195 100644
--- a/gas/testsuite/gas/macros/count.l
+++ b/gas/testsuite/gas/macros/count.l
@@ -8,3 +8,5 @@
1
4
2
+\+
+\+
diff --git a/gas/testsuite/gas/macros/count.s b/gas/testsuite/gas/macros/count.s
index c752ca8367d..ff04e5f4f15 100644
--- a/gas/testsuite/gas/macros/count.s
+++ b/gas/testsuite/gas/macros/count.s
@@ -17,3 +17,7 @@
mac1 2
mac2 3
+
+ .irp i,1,2
+ .print "\+"
+ .endr
--
2.45.0.rc1.225.g2a3ae87e7f-goog
More information about the Binutils
mailing list