1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2017 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * Error reporting functions for the assembler
39 #define NASM_ERROR_H 1
44 * An error reporting function should look like this.
46 void printf_func(2, 3) nasm_error(int severity
, const char *fmt
, ...);
47 no_return
printf_func(2, 3) nasm_fatal(int flags
, const char *fmt
, ...);
48 no_return
printf_func(2, 3) nasm_panic(int flags
, const char *fmt
, ...);
49 no_return
nasm_panic_from_macro(const char *file
, int line
);
50 #define panic() nasm_panic_from_macro(__FILE__, __LINE__);
52 typedef void (*vefunc
) (int severity
, const char *fmt
, va_list ap
);
53 extern vefunc nasm_verror
;
54 static inline vefunc
nasm_set_verror(vefunc ve
)
56 vefunc old_verror
= nasm_verror
;
62 * These are the error severity codes which get passed as the first
63 * argument to an efunc.
66 #define ERR_DEBUG 0x00000000 /* put out debugging message */
67 #define ERR_WARNING 0x00000001 /* warn only: no further action */
68 #define ERR_NONFATAL 0x00000002 /* terminate assembly after phase */
69 #define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */
70 #define ERR_PANIC 0x00000007 /* internal error: panic instantly
71 * and dump core for reference */
72 #define ERR_MASK 0x00000007 /* mask off the above codes */
73 #define ERR_NOFILE 0x00000010 /* don't give source file name/line */
74 #define ERR_USAGE 0x00000020 /* print a usage message */
75 #define ERR_PASS1 0x00000040 /* only print this error on pass one */
76 #define ERR_PASS2 0x00000080
78 #define ERR_NO_SEVERITY 0x00000100 /* suppress printing severity */
79 #define ERR_PP_PRECOND 0x00000200 /* for preprocessor use */
80 #define ERR_PP_LISTMACRO 0x00000400 /* from preproc->error_list_macros() */
83 * These codes define specific types of suppressible warning.
86 #define ERR_WARN_MASK 0xFFFFF000 /* the mask for this feature */
87 #define ERR_WARN_SHR 12 /* how far to shift right */
89 #define WARN(x) ((x) << ERR_WARN_SHR)
90 #define WARN_IDX(x) (((x) & ERR_WARN_MASK) >> ERR_WARN_SHR)
92 #define ERR_WARN_OTHER WARN( 0) /* any noncategorized warning */
93 #define ERR_WARN_MNP WARN( 1) /* macro-num-parameters warning */
94 #define ERR_WARN_MSR WARN( 2) /* macro self-reference */
95 #define ERR_WARN_MDP WARN( 3) /* macro default parameters check */
96 #define ERR_WARN_OL WARN( 4) /* orphan label (no colon, and
98 #define ERR_WARN_NOV WARN( 5) /* numeric overflow */
99 #define ERR_WARN_GNUELF WARN( 6) /* using GNU ELF extensions */
100 #define ERR_WARN_FL_OVERFLOW WARN( 7) /* FP overflow */
101 #define ERR_WARN_FL_DENORM WARN( 8) /* FP denormal */
102 #define ERR_WARN_FL_UNDERFLOW WARN( 9) /* FP underflow */
103 #define ERR_WARN_FL_TOOLONG WARN(10) /* FP too many digits */
104 #define ERR_WARN_USER WARN(11) /* %warning directives */
105 #define ERR_WARN_LOCK WARN(12) /* bad LOCK prefixes */
106 #define ERR_WARN_HLE WARN(13) /* bad HLE prefixes */
107 #define ERR_WARN_BND WARN(14) /* bad BND prefixes */
108 #define ERR_WARN_ZEXTRELOC WARN(15) /* relocation zero-extended */
109 #define ERR_WARN_PTR WARN(16) /* not a NASM keyword */
110 #define ERR_WARN_BAD_PRAGMA WARN(17) /* malformed pragma */
111 #define ERR_WARN_UNKNOWN_PRAGMA WARN(18) /* unknown pragma */
112 #define ERR_WARN_NOTMY_PRAGMA WARN(19) /* pragma inapplicable */
113 #define ERR_WARN_UNK_WARNING WARN(20) /* unknown warning */
115 /* The "all" warning acts as a global switch, it must come last */
116 #define ERR_WARN_ALL 21 /* Do not use WARN() here */
123 extern const struct warning warnings
[ERR_WARN_ALL
+1];
125 /* This is a bitmask */
126 #define WARN_ST_ENABLED 1 /* Warning is currently enabled */
127 #define WARN_ST_ERROR 2 /* Treat this warning as an error */
129 extern uint8_t warning_state
[ERR_WARN_ALL
];
130 extern uint8_t warning_state_init
[ERR_WARN_ALL
];
132 /* Process a warning option or directive */
133 bool set_warning_status(const char *);
135 #endif /* NASM_ERROR_H */