enum { WE_UNKNOWN, WE_ERROR, WE_WARNING, WE_PARSERERROR } type;
unsigned long line;
+ unsigned long displine;
+
/* FIXME: This should not be a fixed size. But we don't have vasprintf()
* right now. */
char msg[MSG_MAXSIZE];
* type is WE_PARSERERROR.
*/
static errwarn_data *
-errwarn_data_new(unsigned long line, int replace_parser_error)
+errwarn_data_new(unsigned long line, unsigned long displine,
+ int replace_parser_error)
{
errwarn_data *first, *next, *ins_we, *we;
enum { INS_NONE, INS_HEAD, INS_AFTER } action = INS_NONE;
we->type = WE_UNKNOWN;
we->line = line;
+ we->displine = displine;
if (action == INS_HEAD)
SLIST_INSERT_HEAD(&errwarns, we, link);
return we;
}
-/* Register an error at line line. Does not print the error, only stores it
- * for output_all() to print.
+/* Register an error at line line, displaying line displine. Does not print
+ * the error, only stores it for output_all() to print.
*/
void
-yasm__error_va(unsigned long line, const char *fmt, va_list va)
+yasm__error_va_at(unsigned long line, unsigned long displine, const char *fmt,
+ va_list va)
{
- errwarn_data *we = errwarn_data_new(line, 1);
+ errwarn_data *we = errwarn_data_new(line, displine, 1);
we->type = WE_ERROR;
error_count++;
}
-/* Register an warning at line line. Does not print the warning, only stores
- * it for output_all() to print.
+/* Register an warning at line line, displaying line displine. Does not print
+ * the warning, only stores it for output_all() to print.
*/
void
-yasm__warning_va(yasm_warn_class num, unsigned long line, const char *fmt,
- va_list va)
+yasm__warning_va_at(yasm_warn_class num, unsigned long line,
+ unsigned long displine, const char *fmt, va_list va)
{
errwarn_data *we;
if (!(warn_class_enabled & (1UL<<num)))
return; /* warning is part of disabled class */
- we = errwarn_data_new(line, 0);
+ we = errwarn_data_new(line, displine, 0);
we->type = WE_WARNING;
{
va_list va;
va_start(va, fmt);
- yasm__error_va(line, fmt, va);
+ yasm__error_va_at(line, line, fmt, va);
+ va_end(va);
+}
+
+/* Register an error at line line, displaying line displine. Does not print
+ * the error, only stores it for output_all() to print.
+ */
+void
+yasm__error_at(unsigned long line, unsigned long displine, const char *fmt,
+ ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ yasm__error_va_at(line, displine, fmt, va);
va_end(va);
}
{
va_list va;
va_start(va, fmt);
- yasm__warning_va(num, line, fmt, va);
+ yasm__warning_va_at(num, line, line, fmt, va);
+ va_end(va);
+}
+
+/* Register an warning at line line, displaying line displine. Does not print
+ * the warning, only stores it for output_all() to print.
+ */
+void
+yasm__warning_at(yasm_warn_class num, unsigned long line,
+ unsigned long displine, const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ yasm__warning_va_at(num, line, line, fmt, va);
va_end(va);
}
/* Output error/warnings. */
SLIST_FOREACH(we, &errwarns, link) {
/* Output error/warning */
- yasm_linemap_lookup(lm, we->line, &filename, &line);
+ yasm_linemap_lookup(lm, we->displine, &filename, &line);
if (we->type == WE_ERROR)
print_error(filename, line, we->msg);
else
*/
extern /*@exits@*/ void (*yasm_fatal) (const char *message, ...);
+/** Log an error at a given line, displaying a different line. va_list version
+ * of yasm__error_at().
+ * \internal
+ * \param line virtual line
+ * \param displine displayed virtual line
+ * \param message printf-like-format message
+ * \param va argument list for message
+ */
+void yasm__error_va_at(unsigned long line, unsigned long displine,
+ const char *message, va_list va);
+
/** Log an error. va_list version of yasm__error().
* \internal
* \param line virtual line
* \param message printf-like-format message
* \param va argument list for message
*/
-void yasm__error_va(unsigned long line, const char *message, va_list va);
+#define yasm__error_va(line, message, va) \
+ yasm__error_va_at(line, line, message, va)
+
+/** Log a warning at a given line, displaying a different line. va_list
+ * version of yasm__warning_at().
+ * \internal
+ * \param wclass warning class
+ * \param line virtual line
+ * \param displine displayed virtual line
+ * \param message printf-like-format message
+ * \param va argument list for message
+ */
+void yasm__warning_va_at(yasm_warn_class wclass, unsigned long line,
+ unsigned long displine, const char *message,
+ va_list va);
/** Log a warning. va_list version of yasm__warning().
* \internal
* \param message printf-like-format message
* \param va argument list for message
*/
-void yasm__warning_va(yasm_warn_class wclass, unsigned long line,
- const char *message, va_list va);
+#define yasm__warning_va(wclass, line, message, va) \
+ yasm__warning_va_at(wclass, line, line, message, va)
/** Log an error. Does not print it out immediately; yasm_errwarn_output_all()
* outputs errors and warnings.
void yasm__error(unsigned long line, const char *message, ...)
/*@printflike@*/;
+/** Log an error at a given line, displaying a different line. Does not print
+ * it out immediately; yasm_errwarn_output_all() outputs errors and warnings.
+ * \internal
+ * \param line virtual line
+ * \param displine displayed virtual line
+ * \param message printf-like-format message
+ * \param ... argument list for message
+ */
+void yasm__error_at(unsigned long line, unsigned long displine,
+ const char *message, ...) /*@printflike@*/;
+
/** Log a warning. Does not print it out immediately;
* yasm_errwarn_output_all() outputs errors and warnings.
* \internal
void yasm__warning(yasm_warn_class wclass, unsigned long line,
const char *message, ...) /*@printflike@*/;
+/** Log a warning at a given line, displaying a different line. Does not print
+ * it out immediately; yasm_errwarn_output_all() outputs errors and warnings.
+ * \internal
+ * \param wclass warning class
+ * \param line virtual line
+ * \param displine displayed virtual line
+ * \param message printf-like-format message
+ * \param ... argument list for message
+ */
+void yasm__warning_at(yasm_warn_class wclass, unsigned long line,
+ unsigned long displine, const char *message, ...)
+ /*@printflike@*/;
+
/** Log a parser error. Parser errors can be overwritten by non-parser errors
* on the same line.
* \internal
/* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */
if ((rec->status & SYM_DEFINED) ||
(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN))) {
- yasm__error(line,
- N_("duplicate definition of `%s'; first defined on line %lu"),
- name, rec->line);
+ yasm__error(line, N_("redefinition of `%s'"), name);
+ yasm__error_at(line, rec->line, N_("`%s' previously defined here"),
+ name);
} else {
rec->line = line; /* set line number of definition */
rec->type = type;
TESTS += bitvect_test
TESTS += floatnum_test
+TESTS += libyasm/tests/libyasm_test.sh
+
+EXTRA_DIST += libyasm/tests/libyasm_test.sh
+EXTRA_DIST += libyasm/tests/duplabel-err.asm
+EXTRA_DIST += libyasm/tests/duplabel-err.errwarn
noinst_PROGRAMS += bitvect_test
noinst_PROGRAMS += floatnum_test
--- /dev/null
+%macro TESTMAC 0
+label:
+ mov ax, 5
+ mov dx, 4
+ mov cx, 3
+%endmacro
+
+db 6
+
+db 7
+
+TESTMAC
+
+db 8
+db 9
+TESTMAC
+db 10
+TESTMAC
--- /dev/null
+-:16: redefinition of `label'
+-:12: `label' previously defined here
+-:18: redefinition of `label'
+-:12: `label' previously defined here
--- /dev/null
+#! /bin/sh
+# $IdPath$
+${srcdir}/out_test.sh libyasm_test libyasm/tests "libyasm" "-f bin" ""
+exit $?