summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-18 22:29:33 +0000
committerChris Lattner <sabre@nondot.org>2009-04-18 22:29:33 +0000
commitbf78da7b3669385b204b7d7736c6dd2dd230a540 (patch)
tree5f38a93d7fb3fcba345155025c9faf03b82a8cec /clang
parent93017cc12a15c742469a57a14f0665143fe440ff (diff)
downloadbcm5719-llvm-bf78da7b3669385b204b7d7736c6dd2dd230a540.tar.gz
bcm5719-llvm-bf78da7b3669385b204b7d7736c6dd2dd230a540.zip
Fix PR3917: the location of a #line directive is the location of the first _.
llvm-svn: 69485
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp4
-rw-r--r--clang/test/Preprocessor/line-directive.c8
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 7e695a542b0..330e2a17aa3 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -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__.
diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c
index 04c69a6791a..a9ed4bcf8cd 100644
--- a/clang/test/Preprocessor/line-directive.c
+++ b/clang/test/Preprocessor/line-directive.c
@@ -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 _ */
+
+
+
OpenPOWER on IntegriCloud