diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-09-24 00:21:58 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-09-24 00:21:58 -0700 |
commit | 8e3f75ea6e8196b80c69a7a29d5dd3513c5de3f1 (patch) | |
tree | 9a545a70459b5c21ef20af668a1b271fc8827d5a | |
parent | 7f596e7aa8774b1c8d9e3fcf6371b5687464568e (diff) | |
download | nasm-8e3f75ea6e8196b80c69a7a29d5dd3513c5de3f1.tar.gz nasm-8e3f75ea6e8196b80c69a7a29d5dd3513c5de3f1.tar.bz2 nasm-8e3f75ea6e8196b80c69a7a29d5dd3513c5de3f1.zip |
%error, %warning out on the final pass, add %fatal
Only process %error or %warning directives on the final pass. Add a
new %fatal directive which terminates assembly immediately.
-rw-r--r-- | doc/changes.src | 4 | ||||
-rw-r--r-- | doc/nasmdoc.src | 19 | ||||
-rw-r--r-- | pptok.dat | 1 | ||||
-rw-r--r-- | preproc.c | 16 | ||||
-rw-r--r-- | test/fwdoptpp.asm | 133 |
5 files changed, 165 insertions, 8 deletions
diff --git a/doc/changes.src b/doc/changes.src index b39d3a5..ea0a4c7 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -14,6 +14,10 @@ since 2007. \b New \c{%warning} directive to issue user-controlled warnings. +\b \c{%error} directives are now deferred to the final assembly phase. + +\b New \c{%fatal} directive to immediately terminate assembly. + \b \c{__utf16__} and \c{__utf32__} operators to generate UTF-16 and UTF-32 strings. diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index ffd416a..6b5df2f 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -3389,7 +3389,7 @@ the construction of an appropriately sized ENTER instruction as shown in the example. -\H{pperror} Reporting \i{User-Defined Errors}: \i\c{%error} and \i\c{%warning} +\H{pperror} Reporting \i{User-Defined Errors}: \i\c{%error}, \i\c{%warning}, \i\c{%fatal} The preprocessor directive \c{%error} will cause NASM to report an error if it occurs in assembled code. So if other users are going to @@ -3420,10 +3420,19 @@ Similarly, \c{%warning} issues a warning, but allows assembly to continue: \c %define F1 \c %endif -It is optional for the message string after \c{%error} or \c{%warning} -to be quoted. If it is \e{not}, then single-line macros are expanded -in it, which can be used to display more information to the user. For -example: +\c{%error} and \c{%warning} are issued only on the final assembly +pass. This makes them safe to use in conjunction with tests that +depend on symbol values. + +\c{%fatal} terminates assembly immediately, regardless of pass. This +is useful when there is no point in continuing the assembly further, +and doing so is likely just going to cause a spew of confusing error +messages. + +It is optional for the message string after \c{%error}, \c{%warning} +or \c{%fatal} to be quoted. If it is \e{not}, then single-line macros +are expanded in it, which can be used to display more information to +the user. For example: \c %if foo > 64 \c %assign foo_over foo-64 @@ -27,6 +27,7 @@ %endrep %error %exitrep +%fatal %iassign %idefine %idefstr @@ -1938,6 +1938,7 @@ static int do_directive(Token * tline) MMacro *tmp_defining; /* Used when manipulating rep_nest */ int64_t count; size_t len; + int severity; origline = tline; @@ -2363,12 +2364,21 @@ static int do_directive(Token * tline) free_tlist(origline); return DIRECTIVE_FOUND; + case PP_FATAL: + severity = ERR_FATAL|ERR_NO_SEVERITY; + goto issue_error; case PP_ERROR: + severity = ERR_NONFATAL|ERR_NO_SEVERITY; + goto issue_error; case PP_WARNING: + severity = ERR_WARNING|ERR_NO_SEVERITY; + goto issue_error; + + issue_error: { - int severity = (i == PP_ERROR) - ? ERR_NONFATAL|ERR_NO_SEVERITY - : ERR_WARNING|ERR_NO_SEVERITY; + /* Only error out if this is the final pass */ + if (pass != 2 && i != PP_FATAL) + return DIRECTIVE_FOUND; tline->next = expand_smacro(tline->next); tline = tline->next; diff --git a/test/fwdoptpp.asm b/test/fwdoptpp.asm new file mode 100644 index 0000000..1b04109 --- /dev/null +++ b/test/fwdoptpp.asm @@ -0,0 +1,133 @@ +;Testname=test; Arguments=-fbin -ofwdoptpp.bin; Files=.stdout .stderr fwdoptpp.bin +n0: jmp n1 +n1: jmp n2 +n2: jmp n3 +n3: jmp n4 +n4: jmp n5 +n5: jmp n6 +n6: jmp n7 +n7: jmp n8 +n8: jmp n9 +n9: jmp n10 +n10: jmp n11 +n11: jmp n12 +n12: jmp n13 +n13: jmp n14 +n14: jmp n15 +n15: jmp n16 +n16: jmp n17 +n17: jmp n18 +n18: jmp n19 +n19: jmp n20 +n20: jmp n21 +n21: jmp n22 +n22: jmp n23 +n23: jmp n24 +n24: jmp n25 +n25: jmp n26 +n26: jmp n27 +n27: jmp n28 +n28: jmp n29 +n29: jmp n30 +n30: jmp n31 +n31: jmp n32 +n32: jmp n33 +n33: jmp n34 +n34: jmp n35 +n35: jmp n36 +n36: jmp n37 +n37: jmp n38 +n38: jmp n39 +n39: jmp n40 +n40: jmp n41 +n41: jmp n42 +n42: jmp n43 +n43: jmp n44 +n44: jmp n45 +n45: jmp n46 +n46: jmp n47 +n47: jmp n48 +n48: jmp n49 +n49: jmp n50 +n50: jmp n51 +n51: jmp n52 +n52: jmp n53 +n53: jmp n54 +n54: jmp n55 +n55: jmp n56 +n56: jmp n57 +n57: jmp n58 +n58: jmp n59 +n59: jmp n60 +n60: jmp n61 +n61: jmp n62 +n62: jmp n63 +n63: jmp n64 +n64: jmp n65 +n65: jmp n66 +n66: jmp n67 +n67: jmp n68 +n68: jmp n69 +n69: jmp n70 +n70: jmp n71 +n71: jmp n72 +n72: jmp n73 +n73: jmp n74 +n74: jmp n75 +n75: jmp n76 +n76: jmp n77 +n77: jmp n78 +n78: jmp n79 +n79: jmp n80 +n80: jmp n81 +n81: jmp n82 +n82: jmp n83 +n83: jmp n84 +n84: jmp n85 +n85: jmp n86 +n86: jmp n87 +n87: jmp n88 +n88: jmp n89 +n89: jmp n90 +n90: jmp n91 +n91: jmp n92 +n92: jmp n93 +n93: jmp n94 +n94: jmp n95 +n95: jmp n96 +n96: jmp n97 +n97: jmp n98 +n98: jmp n99 +n99: jmp n100 +n100: jmp n101 +n101: jmp n102 +n102: jmp n103 +n103: jmp n104 +n104: jmp n105 +n105: jmp n106 +n106: jmp n107 +n107: jmp n108 +n108: jmp n109 +n109: jmp n110 +n110: jmp n111 +n111: jmp n112 +n112: jmp n113 +n113: jmp n114 +n114: jmp n115 +n115: jmp n116 +n116: jmp n117 +n117: jmp n118 +n118: jmp n119 +n119: jmp n120 +n120: jmp n121 +n121: jmp n122 +n122: jmp n123 +n123: jmp n124 +n124: jmp n125 +n125: jmp n126 +n126: jmp n127 +n127: jmp n0 + +%if ($-$$) > 257 +%fatal "Out of space!" +%endif |