[Mesa-dev] [PATCH] glsl: respect the source number set by #line <line> <source>

Kenneth Graunke kenneth at whitecape.org
Sun Mar 29 18:24:09 PDT 2015


On Monday, March 23, 2015 09:56:52 AM Antia Puentes wrote:
> From GLSL 1.30.10, section 3.3 (Preprocessor):
> "#line line source-string-number ... After processing this directive
> (including its new-line), the implementation will behave as if it is
> compiling at ... source string number source-string-number. Subsequent
> source strings will be numbered sequentially, until another #line
> directive overrides that numbering."
> 
> In the previous implementation the source number was always zero.
> Subsequent source strings are still not numbered sequentially, because
> in the glShaderSource implementation we are concatenating the source code
> strings into one long string.
> 
> Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815
> ---
>  src/glsl/glsl_lexer.ll | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
> index 8dc3d10..f0e047e 100644
> --- a/src/glsl/glsl_lexer.ll
> +++ b/src/glsl/glsl_lexer.ll
> @@ -36,14 +36,13 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *);
>  
>  #define YY_USER_ACTION						\
>     do {								\
> -      yylloc->source = 0;					\
>        yylloc->first_column = yycolumn + 1;			\
>        yylloc->first_line = yylloc->last_line = yylineno + 1;	\
>        yycolumn += yyleng;					\
>        yylloc->last_column = yycolumn + 1;			\
>     } while(0);
>  
> -#define YY_USER_INIT yylineno = 0; yycolumn = 0;
> +#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0;
>  
>  /* A macro for handling reserved words and keywords across language 
versions.
>   *
> 

Looks good to me!  We could probably concatenate the strings together
but put "#line 0 i" between each source string's content, if we wanted
to fix the bug completely.  Seems simple enough.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150329/d67e9137/attachment.sig>


More information about the mesa-dev mailing list