macro-defaults.asm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ;Testname=warning; Arguments=-fbin -omacdef.bin -w+macro-defaults; Files=stdout stderr macdef.bin
  2. ;Testname=nonwarning; Arguments=-fbin -omacdef.bin -w-macro-defaults; Files=stdout stderr macdef.bin
  3. %MACRO mmac_fix 1 a
  4. ; While defined to take one parameter, any invocation will
  5. ; see two, due to the default parameter.
  6. %warning %0 %1 %2 %3 %4 %5
  7. %ENDMACRO
  8. mmac_fix one
  9. %MACRO mmac_var 1-2 a,b
  10. ; While defined to take one or two parameters, invocations
  11. ; will see three, due to the default parameters.
  12. %warning %0 %1 %2 %3 %4 %5
  13. %ENDMACRO
  14. mmac_var one
  15. mmac_var one,two
  16. %MACRO mmac_plus 1-2+ a,b
  17. ; This does not warn. Although this looks like two default
  18. ; parameters, it ends up being only one: the "+" limits it
  19. ; to two parameters; if invoked without a second parameter
  20. ; the second parameter will be "a,b".
  21. %warning %0 %1 %2 %3 %4 %5
  22. ;Check rotating behaviour
  23. %ENDMACRO
  24. mmac_plus one
  25. mmac_plus one,two
  26. mmac_plus one,two,three
  27. %MACRO mmac_star 1-* a,b
  28. ; This does not warn. Because the "*" extends the range of
  29. ; parameters to infinity, the "a,b" default parameters can
  30. ; not exceed that range.
  31. %warning %0 %1 %2 %3 %4 %5
  32. %ENDMACRO
  33. mmac_star one
  34. mmac_star one,two
  35. mmac_star one,two,three
  36. %MACRO mmac_rotate 0-* a,b
  37. %warning %0 %1 %2 %3 %4 %5
  38. ;%rotate should rotate all parameters
  39. %rotate 1
  40. %warning %0 %1 %2 %3 %4 %5
  41. %ENDMACRO
  42. mmac_rotate
  43. mmac_rotate one
  44. mmac_rotate one,two
  45. mmac_rotate one,two,three
  46. ;Scope / evaluation time test
  47. %define I 0
  48. %assign J 0
  49. %xdefine K 0
  50. %MACRO mmac_scope 0 I J K
  51. %warning %1 %2 %3
  52. %ENDMACRO
  53. %define I 1
  54. %assign J 1
  55. %xdefine K 1
  56. mmac_scope