summaryrefslogtreecommitdiff
path: root/test/macro-defaults.asm
diff options
context:
space:
mode:
authorVictor van den Elzen <victor.vde@gmail.com>2008-08-06 14:47:54 +0200
committerVictor van den Elzen <victor.vde@gmail.com>2008-08-06 14:48:55 +0200
commit22343c2c72f0ca6902d3e9573db87fb0f8d1898e (patch)
treeccc33139db31b392268d69a194a7c2fb76fc0c66 /test/macro-defaults.asm
parent932de6c252b2420c3e0f0a8d4d90463d59ae4869 (diff)
downloadnasm-22343c2c72f0ca6902d3e9573db87fb0f8d1898e.tar.gz
Add macro-defaults warning class and documentation.
Diffstat (limited to 'test/macro-defaults.asm')
-rwxr-xr-xtest/macro-defaults.asm64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/macro-defaults.asm b/test/macro-defaults.asm
new file mode 100755
index 00000000..17b1624b
--- /dev/null
+++ b/test/macro-defaults.asm
@@ -0,0 +1,64 @@
+;Testname=warning; Arguments=-fbin -omacdef.bin -w+macro-defaults; Files=.stdout .stderr macdef.bin
+;Testname=nonwarning; Arguments=-fbin -omacdef.bin -w-macro-defaults; Files=.stdout .stderr macdef.bin
+
+%MACRO mmac_fix 1 a
+ ; While defined to take one parameter, any invocation will
+ ; see two, due to the default parameter.
+ %warning %0 %1 %2 %3 %4 %5
+%ENDMACRO
+mmac_fix one
+
+%MACRO mmac_var 1-2 a,b
+ ; While defined to take one or two parameters, invocations
+ ; will see three, due to the default parameters.
+ %warning %0 %1 %2 %3 %4 %5
+%ENDMACRO
+mmac_var one
+mmac_var one,two
+
+%MACRO mmac_plus 1-2+ a,b
+ ; This does not warn. Although this looks like two default
+ ; parameters, it ends up being only one: the "+" limits it
+ ; to two parameters; if invoked without a second parameter
+ ; the second parameter will be "a,b".
+ %warning %0 %1 %2 %3 %4 %5
+ ;Check rotating behaviour
+%ENDMACRO
+mmac_plus one
+mmac_plus one,two
+mmac_plus one,two,three
+
+%MACRO mmac_star 1-* a,b
+ ; This does not warn. Because the "*" extends the range of
+ ; parameters to infinity, the "a,b" default parameters can
+ ; not exceed that range.
+ %warning %0 %1 %2 %3 %4 %5
+%ENDMACRO
+mmac_star one
+mmac_star one,two
+mmac_star one,two,three
+
+%MACRO mmac_rotate 0-* a,b
+ %warning %0 %1 %2 %3 %4 %5
+ ;%rotate should rotate all parameters
+ %rotate 1
+ %warning %0 %1 %2 %3 %4 %5
+%ENDMACRO
+mmac_rotate
+mmac_rotate one
+mmac_rotate one,two
+mmac_rotate one,two,three
+
+;Scope / evaluation time test
+%define I 0
+%assign J 0
+%xdefine K 0
+
+%MACRO mmac_scope 0 I J K
+ %warning %1 %2 %3
+%ENDMACRO
+
+%define I 1
+%assign J 1
+%xdefine K 1
+mmac_scope