glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+
authorAntia Puentes <apuentes@igalia.com>
Tue, 17 Mar 2015 18:12:23 +0000 (19:12 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 6 Apr 2015 06:55:10 +0000 (08:55 +0200)
From GLSL 3.30 and GLSL ES 1.00 on, after processing the line
directive (including its new-line), the implementation should
behave as if it is compiling at the line number passed as
argument. In previous versions, it behaved as if compiling
at the passed line number + 1.

Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/glsl_lexer.ll

index f0e047ebd704aabe684141a2126d730cceb9c7d9..2785ed16884dd457f4048054bcf7654ae34e6991 100644 (file)
@@ -187,6 +187,15 @@ HASH               ^{SPC}#{SPC}
                                    * one-based.
                                    */
                                   yylineno = strtol(ptr, &ptr, 0) - 1;
+
+                                   /* From GLSL 3.30 and GLSL ES on, after processing the
+                                    * line directive (including its new-line), the implementation
+                                    * will behave as if it is compiling at the line number passed
+                                    * as argument. It was line number + 1 in older specifications.
+                                    */
+                                   if (yyextra->is_version(330, 100))
+                                      yylineno--;
+
                                   yylloc->source = strtol(ptr, NULL, 0);
                                }
 {HASH}line{SPCP}{INT}{SPC}$    {
@@ -202,6 +211,14 @@ HASH               ^{SPC}#{SPC}
                                    * one-based.
                                    */
                                   yylineno = strtol(ptr, &ptr, 0) - 1;
+
+                                   /* From GLSL 3.30 and GLSL ES on, after processing the
+                                    * line directive (including its new-line), the implementation
+                                    * will behave as if it is compiling at the line number passed
+                                    * as argument. It was line number + 1 in older specifications.
+                                    */
+                                   if (yyextra->is_version(330, 100))
+                                      yylineno--;
                                }
 ^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}on{SPC}\) {
                                  BEGIN PP;