]> granicus.if.org Git - yasm/commitdiff
Fix error/warnings in the NASM preprocessor to reference the correct line
authorPeter Johnson <peter@tortall.net>
Sat, 7 Oct 2006 17:27:56 +0000 (17:27 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 7 Oct 2006 17:27:56 +0000 (17:27 -0000)
number, rather than the last parsed line number.  Also improve
"cannot reference symbol" error a bit, to include the symbol name.

svn path=/trunk/yasm/; revision=1643

libyasm/linemgr.c
libyasm/linemgr.h
modules/preprocs/nasm/nasm-eval.c
modules/preprocs/nasm/nasm-preproc.c
modules/preprocs/nasm/tests/ifcritical-err.errwarn
modules/preprocs/nasm/tests/nasmpp-nested.errwarn

index 01b10743ea51d9d059e8aa696f9097d09e18ce27..fba32738ab6e8c4fa7933754a307de0b5c56e00b 100644 (file)
@@ -126,6 +126,25 @@ yasm_linemap_set(yasm_linemap *linemap, const char *filename,
     mapping->line_inc = line_inc;
 }
 
+unsigned long
+yasm_linemap_poke(yasm_linemap *linemap, const char *filename,
+                 unsigned long file_line)
+{
+    unsigned long line;
+    line_mapping *mapping = &linemap->map->vector[linemap->map->size-1];
+
+    linemap->current++;
+    yasm_linemap_set(linemap, filename, file_line, 0);
+
+    line = linemap->current;
+
+    linemap->current++;
+    yasm_linemap_set(linemap, mapping->filename, mapping->file_line,
+                    mapping->line_inc);
+
+    return line;
+}
+
 yasm_linemap *
 yasm_linemap_create(void)
 {
index fecf621a05aa56334c21543c20bd9b1b9b87e4a0..09e9cb3be3cf28bf292ae1fe76518209d07bc2e1 100644 (file)
@@ -92,6 +92,18 @@ unsigned long yasm_linemap_goto_next(yasm_linemap *linemap);
 void yasm_linemap_set(yasm_linemap *linemap, /*@null@*/ const char *filename,
                      unsigned long file_line, unsigned long line_inc);
 
+/** Poke a single file/line association, restoring the original physical
+ * association starting point.  Caution: increments the current virtual line
+ * twice.
+ * \param linemap      line mapping repository
+ * \param filename     physical file name (if NULL, not changed)
+ * \param file_line    physical line number
+ * \return The virtual line number of the poked association.
+ */
+unsigned long yasm_linemap_poke(yasm_linemap *linemap,
+                               /*@null@*/ const char *filename,
+                               unsigned long file_line);
+
 /** Look up the associated physical file and line for a virtual line.
  * \param linemap      line mapping repository
  * \param line         virtual line
index b85cfbf546556596a924e37d95598f138acb94f6..66c5c6ed7b774156015aa2e282d857403ede177e 100644 (file)
@@ -382,9 +382,10 @@ static yasm_expr *expr6(void)
          case TOKEN_ID:
          case TOKEN_HERE:
          case TOKEN_BASE:
-           error(ERR_NONFATAL, "%s not supported",
-                 (i == TOKEN_ID ? "symbol references" :
-                  i == TOKEN_HERE ? "`$'" : "`$$'"));
+           error(ERR_NONFATAL,
+                 "cannot reference symbol `%s' in preprocessor",
+                 (i == TOKEN_ID ? tokval->t_charptr :
+                  i == TOKEN_HERE ? "$" : "$$"));
            e = yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_int(1)),
                                       0);
            break;
index b0f8a2eb570ae391c6d71a2891ac2a03b7c9c495..681354ccb36d81bdf3e3dec6c96f23b8c445aee2 100644 (file)
@@ -123,7 +123,9 @@ nasm_efunc(int severity, const char *fmt, ...)
            break;
     }
     va_end(va);
-    yasm_errwarn_propagate(cur_errwarns, yasm_linemap_get_current(cur_lm));
+    yasm_errwarn_propagate(cur_errwarns,
+       yasm_linemap_poke(cur_lm, nasm_src_get_fname(),
+                         (unsigned long)nasm_src_get_linnum()));
 }
 
 static yasm_preproc *
index 7cc27b441f92b5c17a535f4bb02d1ce58cc85508..9c617cf7b5084fb394dc9796ba720d5e6f3922cd 100644 (file)
@@ -1 +1 @@
--:4: symbol references not supported
+-:5: cannot reference symbol `teststringlen' in preprocessor
index 101c132e247987689e9d6857a695d817883288ae..7a9248687f192cbbc53b79a8a11df86289dc4b4c 100644 (file)
@@ -1,3 +1,3 @@
--:26: warning: (WORK_1:4) 0x4
--:26: warning: (WORK_2:4) 0x4
--:26: warning: (DONT_WORK_1:6) 0x4 0x4
+-:27: warning: (WORK_1:4) 0x4
+-:28: warning: (WORK_2:4) 0x4
+-:29: warning: (DONT_WORK_1:6) 0x4 0x4