test: nasm-t -- Update multisection
[nasm.git] / include / error.h
blob9c9352140e3ab5ef7a655d13fe464f6e3ab7fcfb
1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2018 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
9 * conditions are met:
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
38 #ifndef NASM_ERROR_H
39 #define NASM_ERROR_H 1
41 #include "compiler.h"
44 * File pointer for error messages
46 extern FILE *error_file; /* Error file descriptor */
49 * Typedef for the severity field
51 typedef uint32_t errflags;
54 * An error reporting function should look like this.
56 void printf_func(2, 3) nasm_error(errflags severity, const char *fmt, ...);
57 void printf_func(1, 2) nasm_debug(const char *fmt, ...);
58 void printf_func(2, 3) nasm_debugf(errflags flags, const char *fmt, ...);
59 void printf_func(1, 2) nasm_note(const char *fmt, ...);
60 void printf_func(2, 3) nasm_notef(errflags flags, const char *fmt, ...);
61 void printf_func(2, 3) nasm_warn(errflags flags, const char *fmt, ...);
62 void printf_func(1, 2) nasm_nonfatal(const char *fmt, ...);
63 void printf_func(2, 3) nasm_nonfatalf(errflags flags, const char *fmt, ...);
64 fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...);
65 fatal_func printf_func(2, 3) nasm_fatalf(errflags flags, const char *fmt, ...);
66 fatal_func printf_func(1, 2) nasm_panic(const char *fmt, ...);
67 fatal_func printf_func(2, 3) nasm_panicf(errflags flags, const char *fmt, ...);
68 fatal_func nasm_panic_from_macro(const char *file, int line);
69 #define panic() nasm_panic_from_macro(__FILE__, __LINE__);
71 typedef void (*vefunc) (errflags severity, const char *fmt, va_list ap);
72 extern vefunc nasm_verror;
74 static inline vefunc nasm_set_verror(vefunc ve)
76 vefunc old_verror = nasm_verror;
77 nasm_verror = ve;
78 return old_verror;
82 * These are the error severity codes which get passed as the first
83 * argument to an efunc.
85 #define ERR_DEBUG 0x00000000 /* put out debugging message */
86 #define ERR_NOTE 0x00000001 /* additional error information */
87 #define ERR_WARNING 0x00000002 /* warn only: no further action */
88 #define ERR_NONFATAL 0x00000003 /* terminate assembly after phase */
89 #define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */
90 #define ERR_PANIC 0x00000007 /* internal error: panic instantly
91 * and dump core for reference */
92 #define ERR_MASK 0x00000007 /* mask off the above codes */
93 #define ERR_NOFILE 0x00000010 /* don't give source file name/line */
94 #define ERR_HERE 0x00000020 /* point to a specific source location */
95 #define ERR_USAGE 0x00000040 /* print a usage message */
96 #define ERR_PASS1 0x00000080 /* only print this error on pass one */
97 #define ERR_PASS2 0x00000100 /* only print this error on pass one */
99 #define ERR_NO_SEVERITY 0x00000200 /* suppress printing severity */
100 #define ERR_PP_PRECOND 0x00000400 /* for preprocessor use */
101 #define ERR_PP_LISTMACRO 0x00000800 /* from preproc->error_list_macros() */
104 * These codes define specific types of suppressible warning.
105 * They are assumed to occupy the most significant bits of the
106 * severity code.
108 #define WARN_SHR 12 /* how far to shift right */
109 #define WARN_IDX(x) (((errflags)(x)) >> WARN_SHR)
110 #define WARN_MASK ((~(errflags)0) << WARN_SHR)
112 /* This is a bitmask */
113 #define WARN_ST_ENABLED 1 /* Warning is currently enabled */
114 #define WARN_ST_ERROR 2 /* Treat this warning as an error */
116 /* Possible initial state for warnings */
117 #define WARN_INIT_OFF 0
118 #define WARN_INIT_ON WARN_ST_ENABLED
119 #define WARN_INIT_ERR (WARN_ST_ENABLED|WARN_ST_ERROR)
121 /* Process a warning option or directive */
122 bool set_warning_status(const char *value);
124 /* Should be included from within error.h only */
125 #include "warnings.h"
127 #endif /* NASM_ERROR_H */