[Mesa-dev] [PATCH 1/2] glcpp: Allow integer expression for #line directive.

Carl Worth cworth at cworth.org
Tue Jan 28 17:56:02 PST 2014


The GLSL specification explicitly allows for an in integer expression here,
not just a literal integer. The specification says:

	#line must have, after macro substitution, one of the following forms:

		#line line
		#line line source-string-number

	where line and source-string-number are constant integer expressions.

Previously, the implementation required a literal integer (after substitution)
so things like "#line (25)" or "#line +15" were allowed by the specification
but rejected by the implementation.

With this change to the grammar, #line will accept integer expressions like
these.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72273
---
 src/glsl/glcpp/glcpp-parse.y | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 17bc649..2d9008a 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -221,7 +221,7 @@ expanded_line:
 |	ELIF_EXPANDED expression NEWLINE {
 		_glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2);
 	}
-|	LINE_EXPANDED integer_constant NEWLINE {
+|	LINE_EXPANDED expression NEWLINE {
 		parser->has_new_line_number = 1;
 		parser->new_line_number = $2;
 		ralloc_asprintf_rewrite_tail (&parser->output,
@@ -229,7 +229,7 @@ expanded_line:
 					      "#line %" PRIiMAX "\n",
 					      $2);
 	}
-|	LINE_EXPANDED integer_constant integer_constant NEWLINE {
+|	LINE_EXPANDED expression integer_constant NEWLINE {
 		parser->has_new_line_number = 1;
 		parser->new_line_number = $2;
 		parser->has_new_source_number = 1;
-- 
1.8.5.2



More information about the mesa-dev mailing list