diff options
author | Nick Clifton <nickc@redhat.com> | 2024-12-19 09:59:11 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2024-12-19 09:59:11 +0000 |
commit | 9f2e3c21f6506f081f1360f02b847606e0e00995 (patch) | |
tree | bfa1409aea4c8df3dd14b0ec7c461109620560c9 /gas/testsuite | |
parent | 2c0c13933a6d08ae87c2852b3421ede090499f09 (diff) | |
download | gdb-9f2e3c21f6506f081f1360f02b847606e0e00995.zip gdb-9f2e3c21f6506f081f1360f02b847606e0e00995.tar.gz gdb-9f2e3c21f6506f081f1360f02b847606e0e00995.tar.bz2 |
Fix the handling or arguments and macro pseudo-variables inside nested assembler macros.
PR 32391
Diffstat (limited to 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/macros/macros.exp | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/macros/nesting.d | 28 | ||||
-rw-r--r-- | gas/testsuite/gas/macros/nesting.s | 104 |
3 files changed, 133 insertions, 0 deletions
diff --git a/gas/testsuite/gas/macros/macros.exp b/gas/testsuite/gas/macros/macros.exp index 3ac199f..94ac37c 100644 --- a/gas/testsuite/gas/macros/macros.exp +++ b/gas/testsuite/gas/macros/macros.exp @@ -112,3 +112,4 @@ run_list_test count run_list_test irp-count run_list_test irpc-quote run_list_test rept-count +run_dump_test nesting diff --git a/gas/testsuite/gas/macros/nesting.d b/gas/testsuite/gas/macros/nesting.d new file mode 100644 index 0000000..2f44aed --- /dev/null +++ b/gas/testsuite/gas/macros/nesting.d @@ -0,0 +1,28 @@ +#nm: -j +#name: Nested macros (PR 32391) +# Sone targets do not support macros used like this. +#skip: tic*-*-* mmix-* + +#... +_m7_ +_m8_ +after_at_0 +after_at_3 +after_plus_0 +after_plus_1 +before_at_0 +before_at_3 +before_plus_0 +before_plus_1 +bert +harryfred +i3_bar +inside_at_1 +inside_at_2 +inside_at_4 +inside_at_5 +inside_plus_0 +inside_plus_1 +jim +o3_foo +other_inner_6 diff --git a/gas/testsuite/gas/macros/nesting.s b/gas/testsuite/gas/macros/nesting.s new file mode 100644 index 0000000..438d5af --- /dev/null +++ b/gas/testsuite/gas/macros/nesting.s @@ -0,0 +1,104 @@ + + .text +/* PR 32391: Automatic counters inside macros should increment when nested + macros finish execution. */ +.macro o1 +.global before_at_\@ +before_at_\@: +.global before_plus_\+ +before_plus_\+: + + .macro i1 +.global inside_at_\@ +inside_at_\@: +.global inside_plus_\+ +inside_plus_\+: + .endm + + i1 + i1 + +.global after_at_\@ +after_at_\@: +.global after_plus_\+ +after_plus_\+: + +.endm + +/* Invoking o1 should produce these symbols in this order: + + before_at_0 + before_plus_0 + inside_at_1 + inside_plus_0 + inside_at_2 + inside_plus_1 + after_at_0 + after_plus_0 */ +o1 + +/* A second invocation of o1 should not produce any errors about + symbols or macros being redefined. */ +o1 + +/* This definition should not collide with the definition inside o1. */ +.macro i1 +.global other_inner_\@ +other_inner_\@: +.endm + +/* And invoking it should invoke the second defintion of i1, not the first. */ +i1 + +.macro o2 +.global _m\@_ +_m\@_: +.macro i2 +.global _m\@_ +_m\@_: +.endm +i2 +.endm + +/* This should not generate conflicting symbols because the assembler + inserts the contents of o2 into the input buffer as pure text (ie + without evaluating i2). The first use of \@ is evaluated at this + time, creating _m4_. But the second use is not evaluated because + it is inside a .macro definition. + + This finishes the evaluation of o2, so the \@ counter is incremented. + + Next the input buffer is re-evaluated and the i2 macro definition + and invocation are encounterd. The text from i2 are inserted into + the input buffer and at this point the second use of \@ is evaluated + resulting in the creation of a symbol called _m5_. */ +o2 + +/* Macro arguments should be independent of nesting. */ +.macro O3 arg +.global o3_\arg +o3_\arg: + + .macro I3 arg +.global i3_\arg +i3_\arg: + .endm + + i3 bar /* Macro names are case insensitive. */ +.endm + +o3 foo /* Should produce two labels: o3_foo and i3_bar. */ + +/* Nested macros can access the arguments of their parents. + In addition their arguments can be substituted into the arguments + that are substited from their parents: */ +.macro OUTER arg1, arg2, arg3:vararg + .macro INNER arg4 arg2 + .dc.a \arg2 + .dc.a \arg3 + .endm + INNER \arg1 bert + .dc.a \arg2 +.endm + +OUTER fred, jim, harry\arg4 /* This produces references to "jim", "bert" and "harryfred". */ |