glcpp: Add a newline to expanded #line directives.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 28 Jul 2012 20:04:53 +0000 (13:04 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 28 Jul 2012 20:33:50 +0000 (13:33 -0700)
Otherwise, the preprocessor happily outputs

    #line 2 4 <your next line of code>

and the main compiler gets horribly confused and fails to compile.

This is not the right solution (line numbers in error messages will
likely be off-by-one in certain circumstances), but until Carl comes
up with a proper fix, this gets programs running again.

Fixes regressions in Regnum Online, Overgrowth, Piglit, and others since
commit aac78ce8234d96932c38b3f48b1d828077bc0027.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51802
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51506
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41152
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/glcpp/glcpp-parse.y

index c0c1ca197c5c929c617fed85fe90e55c6480051b..bf6f3ad019b537cf4dd27be07beb1f8e794430ac 100644 (file)
@@ -213,7 +213,7 @@ expanded_line:
                parser->new_line_number = $2;
                ralloc_asprintf_rewrite_tail (&parser->output,
                                              &parser->output_length,
-                                             "#line %" PRIiMAX,
+                                             "#line %" PRIiMAX "\n",
                                              $2);
        }
 |      LINE_EXPANDED integer_constant integer_constant NEWLINE {
@@ -223,7 +223,7 @@ expanded_line:
                parser->new_source_number = $3;
                ralloc_asprintf_rewrite_tail (&parser->output,
                                              &parser->output_length,
-                                             "#line %" PRIiMAX " %" PRIiMAX,
+                                             "#line %" PRIiMAX " %" PRIiMAX "\n",
                                              $2, $3);
        }
 ;