From: Russ Cox Date: Tue, 3 Feb 2015 16:48:50 +0000 (-0500) Subject: [dev.cc] cmd/6a, etc: fix line number accounting during #ifdef X-Git-Tag: go1.5beta1~1915^2~84 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=975c82fd9b58b5ff4cab4fff2327308e1fcaf427;p=gostls13.git [dev.cc] cmd/6a, etc: fix line number accounting during #ifdef 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 --- diff --git a/src/cmd/cc/lexbody b/src/cmd/cc/lexbody index f586aaa20e..4749273eba 100644 --- a/src/cmd/cc/lexbody +++ b/src/cmd/cc/lexbody @@ -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) diff --git a/src/cmd/internal/asm/lexbody.go b/src/cmd/internal/asm/lexbody.go index df0407c7a9..14a82f8228 100644 --- a/src/cmd/internal/asm/lexbody.go +++ b/src/cmd/internal/asm/lexbody.go @@ -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 }