]> granicus.if.org Git - yasm/commitdiff
GAS preproc: Fix line number for .rept without matching .endr error.
authorPeter Johnson <peter@tortall.net>
Sun, 3 Jan 2010 21:59:28 +0000 (21:59 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 3 Jan 2010 21:59:28 +0000 (21:59 -0000)
The line number reported for the error is that of the .rept directive.

Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

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

modules/parsers/gas/tests/bin/rept-err.asm
modules/parsers/gas/tests/bin/rept-err.errwarn
modules/preprocs/gas/gas-preproc.c

index 143e904136c6504f76d5a25bc1efc165b16f68d5..88582f9320dfb35c72ac692ef2927dbdc921f0cf 100644 (file)
@@ -1,2 +1,4 @@
 .rept 6
+.endr
+.rept 3
 .byte 0
index 3f64c8eb8c9b77d6c1f7104fd9a75924dc2bd286..5682b14a30a44843e626d7eb44295f41aa9acdce 100644 (file)
@@ -1 +1 @@
--:1: error: rept without matching endr
+-:3: error: rept without matching endr
index e81bb897589c54b20db2b360611c8a3bad4aa7cb..998070bbc86e7807fb53facbb091a0ad0ade7308 100644 (file)
@@ -644,6 +644,8 @@ static int eval_rept(yasm_preproc_gas *pp, int unused, const char *arg1)
     char *line = read_line(pp);
     buffered_line *prev_bline = NULL;
     SLIST_HEAD(buffered_lines_head, buffered_line) lines;
+    int rept_start_file_line_number = pp->next_line_number - 1;
+    int rept_start_output_line_number = pp->current_line_number;
 
     SLIST_INIT(&lines);
 
@@ -696,8 +698,9 @@ static int eval_rept(yasm_preproc_gas *pp, int unused, const char *arg1)
         line = read_line(pp);
         num_lines++;
     }
+    yasm_linemap_set(pp->cur_lm, pp->in_filename, rept_start_output_line_number, rept_start_file_line_number, 0);
     yasm_error_set(YASM_ERROR_SYNTAX, N_("rept without matching endr"));
-    yasm_errwarn_propagate(pp->errwarns, pp->current_line_number);
+    yasm_errwarn_propagate(pp->errwarns, rept_start_output_line_number);
     return 0;
 }