Re: [Mesa-dev] [PATCH] glsl: skip stringification in preprocessor if in unreachable branch

2018-08-29 Thread Ian Romanick
On 08/28/2018 06:36 PM, Timothy Arceri wrote:
> This fixes compilation of some "No Mans Sky" shaders where the stringification
> happens in branches intended for DX12.

I was going to complain that this would make things like the following
compile:

#version 110

#ifdef this_is_undefined
#is_this_valid_too
#endif

void main() { }

This already compiles.  Looking at the C99 spec and testing with GCC,
this is intentional.  We should probably add that as another
preprocessor test.

This patch is

Reviewed-by: Ian Romanick 

> ---
> 
>  Piglit tests: https://patchwork.freedesktop.org/series/48850/
> 
>  src/compiler/glsl/glcpp/glcpp-lex.l | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/compiler/glsl/glcpp/glcpp-lex.l 
> b/src/compiler/glsl/glcpp/glcpp-lex.l
> index 9cfcc120222..fe5845acd4e 100644
> --- a/src/compiler/glsl/glcpp/glcpp-lex.l
> +++ b/src/compiler/glsl/glcpp/glcpp-lex.l
> @@ -420,8 +420,10 @@ HEXADECIMAL_INTEGER  0[xX][0-9a-fA-F]+[uU]?
>  
>   /* This will catch any non-directive garbage after a HASH */
>  {NONSPACE} {
> - BEGIN INITIAL;
> - RETURN_TOKEN (GARBAGE);
> + if (!parser->skipping) {
> + BEGIN INITIAL;
> + RETURN_TOKEN (GARBAGE);
> + }
>  }
>  
>   /* An identifier immediately followed by '(' */
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl: skip stringification in preprocessor if in unreachable branch

2018-08-28 Thread Timothy Arceri
This fixes compilation of some "No Mans Sky" shaders where the stringification
happens in branches intended for DX12.

---

 Piglit tests: https://patchwork.freedesktop.org/series/48850/

 src/compiler/glsl/glcpp/glcpp-lex.l | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/glcpp/glcpp-lex.l 
b/src/compiler/glsl/glcpp/glcpp-lex.l
index 9cfcc120222..fe5845acd4e 100644
--- a/src/compiler/glsl/glcpp/glcpp-lex.l
+++ b/src/compiler/glsl/glcpp/glcpp-lex.l
@@ -420,8 +420,10 @@ HEXADECIMAL_INTEGER0[xX][0-9a-fA-F]+[uU]?
 
/* This will catch any non-directive garbage after a HASH */
 {NONSPACE} {
-   BEGIN INITIAL;
-   RETURN_TOKEN (GARBAGE);
+   if (!parser->skipping) {
+   BEGIN INITIAL;
+   RETURN_TOKEN (GARBAGE);
+   }
 }
 
/* An identifier immediately followed by '(' */
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev