[Piglit] [PATCH] Comment continuation in the middle of a define.

Brian Paul brianp at vmware.com
Thu Oct 25 07:55:37 PDT 2012


On 10/25/2012 07:40 AM, jfonseca at vmware.com wrote:
> From: José Fonseca<jfonseca at vmware.com>
>
> ---
>   .../glsl2/comment-continuation-preprocessor.frag   |   34 ++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>   create mode 100644 tests/glslparsertest/glsl2/comment-continuation-preprocessor.frag
>
> diff --git a/tests/glslparsertest/glsl2/comment-continuation-preprocessor.frag b/tests/glslparsertest/glsl2/comment-continuation-preprocessor.frag
> new file mode 100644
> index 0000000..21b889b
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/comment-continuation-preprocessor.frag
> @@ -0,0 +1,34 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.20
> +//
> +// [end config]
> +//
> +// GLSL specification states that
> +//
> +//   Removal of new lines by the line-continuation character ( \ ) logically
> +//   occurs before comments are processed.
> +//
> +// GNU cpp does the same. However NVIDIA accepts the shader below.
> +//
> +// This was seen with MindCAD 3D Viewer.
> +//
> +
> +#define DECLARE_FOO()                                                      \
> +    void foo(out vec4 color)                                               \
> +    {                                                                      \
> +        color = vec4(0, 1, 0, 1);                                          \
> +                                                                           \
> +//      if (0)                                                             \
> +//      {                                                                  \
> +//           color = vec4(0, 0, 1, 1) ;                                    \
> +//      }                                                                  \
> +    }
> +
> +DECLARE_FOO()
> +
> +void main()
> +{
> +     foo(gl_FragColor);
> +}
> +

I might beef-up the comment to point out that the first // in the 
macro effectively makes the rest of the macro's characters go away, 
and hence, produces a compilation error.

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the Piglit mailing list