]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.cc] cmd/6a, etc: fix line number accounting during #ifdef
authorRuss Cox <rsc@golang.org>
Tue, 3 Feb 2015 16:48:50 +0000 (11:48 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 3 Feb 2015 17:41:25 +0000 (17:41 +0000)
Lines beginning with #ifdef, #else, #endif were not incrementing
the line number, resulting in bad line number information for
assembly files with #ifdefs.

Example:

#ifndef GOARCH_ppc64
#endif
#ifdef GOARCH_ppc64le
#endif

TEXT ·use(SB),7,$0
RET

Before this change, the line number recorded for use in 6a -S output
(and in the runtime information in the binary) was 4 too low.

Change-Id: I23e599112ec9919f72e53ac82d9bebbbae3439ed
Reviewed-on: https://go-review.googlesource.com/3783
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/cc/lexbody
src/cmd/internal/asm/lexbody.go

index f586aaa20e670994081be7dfd388ba92b8f3aec5..4749273eba88d20dc97545dd0006831a149d6c55 100644 (file)
@@ -572,6 +572,8 @@ getc(void)
        c = peekc;
        if(c != IGN) {
                peekc = IGN;
+               if(c == '\n')
+                       lineno++;
                return c;
        }
        c = GETC();
@@ -633,7 +635,7 @@ loop:
                                return l;
                        }
                }
-               peekc = c;
+               unget(c);
                return l;
        }
        switch(c)
index df0407c7a97fb1845ffaa80bb68ced2bd4a51308..14a82f822825a82b2fed85d92d393e4faf5bc413 100644 (file)
@@ -534,6 +534,9 @@ func getc() int {
        c = peekc
        if c != IGN {
                peekc = IGN
+               if c == '\n' {
+                       Lineno++
+               }
                return c
        }
 
@@ -599,6 +602,7 @@ loop:
                }
 
                peekc = c
+               unget(c)
                return l
        }