Fix PR3917: the location of a #line directive is the location of the first _.

llvm-svn: 69485
This commit is contained in:
Chris Lattner 2009-04-18 22:29:33 +00:00
parent 93017cc12a
commit bf78da7b36
2 changed files with 12 additions and 0 deletions

View File

@ -485,6 +485,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// be affected by #line.
SourceLocation Loc = Tok.getLocation();
// Advance to the location of the first _, this might not be the first byte
// of the token if it starts with an escaped newline.
Loc = AdvanceToTokenCharacter(Loc, 0);
// One wrinkle here is that GCC expands __LINE__ to location of the *end* of
// a macro instantiation. This doesn't matter for object-like macros, but
// can matter for a function-like macro that expands to contain __LINE__.

View File

@ -79,3 +79,11 @@ typedef int w; // expected-error {{redefinition of typedef 'w' is invalid in C}
#line 010 // expected-warning {{#line directive interprets number as decimal, not octal}}
extern int array[__LINE__ == 10 ? 1:-1];
/* PR3917 */
#line 41
extern char array2[\
_\
_LINE__ == 42 ? 1: -1]; /* line marker is location of first _ */