[binutils-gdb] gas: Fix \+ expansion for .irp and .irpc
Fangrui Song
maskray@sourceware.org
Wed May 15 22:05:32 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b1d28350499d0553067e774f72e4e98c836ae92f
commit b1d28350499d0553067e774f72e4e98c836ae92f
Author: Fangrui Song <maskray@gcc.gnu.org>
Date: Wed May 15 15:05:30 2024 -0700
gas: Fix \+ expansion for .irp and .irpc
.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>
Diff:
---
gas/macro.c | 2 +-
gas/testsuite/gas/macros/count.l | 2 ++
gas/testsuite/gas/macros/count.s | 7 +++++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/gas/macro.c b/gas/macro.c
index 72d869d317f..3036e6a5866 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 (macro && src < in->len && in->ptr[src] == '+')
{
/* 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..4a5b078ba60 100644
--- a/gas/testsuite/gas/macros/count.s
+++ b/gas/testsuite/gas/macros/count.s
@@ -17,3 +17,10 @@
mac1 2
mac2 3
+
+ .irp i,1
+ .print "\+"
+ .endr
+ .irpc i,1
+ .print "\+"
+ .endr
More information about the Binutils-cvs
mailing list