Mesa (master): glcpp: don't push #line directives into next line

Matt Turner mattst88 at kemper.freedesktop.org
Fri Nov 9 22:31:36 UTC 2012


Module: Mesa
Branch: master
Commit: 9ad71c44fa316314551b8540241e81b296d35f44
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ad71c44fa316314551b8540241e81b296d35f44

Author: Fabian Bieler <fabianbieler at fastmail.fm>
Date:   Tue Jul 24 15:36:46 2012 +0200

glcpp: don't push #line directives into next line

By moving the HASH_LINE rule out of control_line: and into line:, we avoid
adding control_line's additional \n (as seen in the first hunk).

mattst88: Carl and I determined independently of Fabian that the 091
test needed to be modified identically to this, and our patch to fix the
test was more complicated.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51506
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Carl Worth <cworth at cworth.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/glcpp/glcpp-parse.y                  |   16 ++++++++--------
 src/glsl/glcpp/tests/091-hash-line.c.expected |    2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 16d2965..9628637 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -190,6 +190,14 @@ line:
 	control_line {
 		ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
 	}
+|	HASH_LINE pp_tokens NEWLINE {
+		if (parser->skip_stack == NULL ||
+		    parser->skip_stack->type == SKIP_NO_SKIP)
+		{
+			_glcpp_parser_expand_and_lex_from (parser,
+							   LINE_EXPANDED, $2);
+		}
+	}
 |	text_line {
 		_glcpp_parser_print_expanded_token_list (parser, $1);
 		ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
@@ -244,14 +252,6 @@ control_line:
 		}
 		ralloc_free ($2);
 	}
-|	HASH_LINE pp_tokens NEWLINE {
-		if (parser->skip_stack == NULL ||
-		    parser->skip_stack->type == SKIP_NO_SKIP)
-		{
-			_glcpp_parser_expand_and_lex_from (parser,
-							   LINE_EXPANDED, $2);
-		}
-	}
 |	HASH_IF conditional_tokens NEWLINE {
 		/* Be careful to only evaluate the 'if' expression if
 		 * we are not skipping. When we are skipping, we
diff --git a/src/glsl/glcpp/tests/091-hash-line.c.expected b/src/glsl/glcpp/tests/091-hash-line.c.expected
index 976d178..48af0b2 100644
--- a/src/glsl/glcpp/tests/091-hash-line.c.expected
+++ b/src/glsl/glcpp/tests/091-hash-line.c.expected
@@ -2,7 +2,6 @@
 0:25(1): preprocessor error: #error line 25 error
 1:0(1): preprocessor error: #error source 1, line 0 error
 2:30(1): preprocessor error: #error source 2, line 30 error
-
 #line 0
 
 #line 25
@@ -17,3 +16,4 @@
 #line 90 2
 
 #line 180 2
+




More information about the mesa-commit mailing list