blob: 3dbf8879c5334147b15dd26e43232a8d07d57129 [file] [log] [blame]
From 241992fd4da6ff012b2593c9160f06d72f1f0f63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tapani=20P=C3=A4lli?= <tapani.palli@intel.com>
Date: Tue, 18 Oct 2016 14:23:47 +0300
Subject: [PATCH] FROMLIST: glcpp: Hack to handle expressions in #line
directives.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GLSL ES 320 technically allows #line to have arbitrary expression trees
rather than integer literal constants, unlike the C and C++ preprocessor.
This is likely a completely unused feature that does not make sense.
However, Android irritatingly mandates this useless behavior, so this
patch implements a hack to try and support it.
We handle a single expression:
#line <line number expression>
but we avoid handling the double expression:
#line <line number expression> <source string expression>
because this is an ambiguous grammar. Instead, we handle the case that
wraps both in parenthesis, which is actually well defined:
#line (<line number expression>) (<source string expression>)
With this change following tests pass:
dEQP-GLES3.functional.shaders.preprocessor.builtin.line_expression_vertex
dEQP-GLES3.functional.shaders.preprocessor.builtin.line_expression_fragment
dEQP-GLES3.functional.shaders.preprocessor.builtin.line_and_file_expression_vertex
dEQP-GLES3.functional.shaders.preprocessor.builtin.line_and_file_expression_fragment
Signed-off-by: Tapani Pรคlli <tapani.palli@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
BUG=b:33352633
BUG=b:33247335
TEST=affected tests passing on CTS 7.1_r1 sentry
Change-Id: I7afbbb386bd4a582e3f241014a83eaccad1d50d9
Reviewed-on: https://chromium-review.googlesource.com/427305
Tested-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Commit-Queue: Haixia Shi <hshi@chromium.org>
Trybot-Ready: Haixia Shi <hshi@chromium.org>
[chadv: Cherry-picked from branch arc-12.1.0-pre2]
(cherry picked from commit 18675d69bcd2a66483fcfc15f4c5fa5db4c257af)
---
src/compiler/glsl/glcpp/glcpp-parse.y | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index e113253061..17c6b9d053 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -225,13 +225,16 @@ expanded_line:
glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro);
_glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2.value);
}
-| LINE_EXPANDED integer_constant NEWLINE {
+| LINE_EXPANDED expression NEWLINE {
+ if (parser->is_gles && $2.undefined_macro)
+ glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro);
parser->has_new_line_number = 1;
- parser->new_line_number = $2;
+ parser->new_line_number = $2.value;
ralloc_asprintf_rewrite_tail (&parser->output,
&parser->output_length,
"#line %" PRIiMAX "\n",
- $2);
+ $2.value);
+
}
| LINE_EXPANDED integer_constant integer_constant NEWLINE {
parser->has_new_line_number = 1;
@@ -243,6 +246,20 @@ expanded_line:
"#line %" PRIiMAX " %" PRIiMAX "\n",
$2, $3);
}
+| LINE_EXPANDED '(' expression ')' '(' expression ')' NEWLINE {
+ if (parser->is_gles && $3.undefined_macro)
+ glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $3.undefined_macro);
+ if (parser->is_gles && $6.undefined_macro)
+ glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $6.undefined_macro);
+ parser->has_new_line_number = 1;
+ parser->new_line_number = $3.value;
+ parser->has_new_source_number = 1;
+ parser->new_source_number = $6.value;
+ ralloc_asprintf_rewrite_tail (&parser->output,
+ &parser->output_length,
+ "#line %" PRIiMAX " %" PRIiMAX "\n",
+ $3.value, $6.value);
+ }
;
define:
--
2.11.0