[Piglit] [PATCH] glsl-1.10: Test that empty declarations are allowed

Ian Romanick idr at freedesktop.org
Fri Aug 5 14:03:42 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/05/2011 12:34 PM, Chad Versace wrote:
> This tests that each of the following empty declarations is allowed:
>     vert, local:     float
>     vert, local:     const float
>     vert, global:    float
>     vert, global:    const float
>     vert, attribute: float
>     vert, varying:   float
>     vert, uniform:   float
> 
> Surprisingly, the formal GLSL grammar allows empty declarations.  From
> page 68 (page 74 of pdf) of the GLSL 1.10 spec:
>      init_declarator_list:
>          single_declaration
>          ...
> 
>      single_declaration:
>          fully_specified_type
>          ...
> 
>      fully_specified_type:
>          type_specifier
>          type_qualifier type_specifier
> 
> Since this property of the grammar is consistent through all versions of
> GLSL (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> 
> Moreover, C99 allows empty declarations. The program below successfully
> compiles with `gcc --std=c99`.
>     float;
>     int main() { return 0; }

These look good, but there are a couple things that should be added:

1. Check the GLSL ES spec for the same issue.  If it exists there, make
'#version 100' tests as well.

2. Check the GLSL spec for other cases that may have this issue.  Can
you use a qualifier (e.g., uniform) with an incomplete declaration?
Make tests (positive or negative) for those as well.

Before these get committed, I'd also like to see the commit message
enumerate the platforms that pass / fail with some brief explanation.
"XYZ driver / OS passes."   "ABC driver / OS fails because of this,
that, and the other thing."

> CC: Paul Berry <sterotype441 at gmail.com>
> CC: Chia-I Wu <olv at lunarg.com>
> Signed-off-by: Chad Versace <chad at chad-versace.us>
> ---
>  .../empty-declaration-attribute-float.vert         |   39 +++++++++++++++++++
>  .../empty-declaration-global-const-float.vert      |   39 +++++++++++++++++++
>  ...mpty-declaration-global-no-qualifier-float.vert |   40 ++++++++++++++++++++
>  .../empty-declaration-local-const-float.vert       |   40 ++++++++++++++++++++
>  ...empty-declaration-local-no-qualifier-float.vert |   40 ++++++++++++++++++++
>  .../empty-declaration-uniform-float.vert           |   39 +++++++++++++++++++
>  .../empty-declaration-varying-float.vert           |   39 +++++++++++++++++++
>  7 files changed, 276 insertions(+), 0 deletions(-)
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-attribute-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-const-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-no-qualifier-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-const-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-no-qualifier-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-uniform-float.vert
>  create mode 100644 tests/spec/glsl-1.10/compiler/declarations/empty-declaration-varying-float.vert
> 
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-attribute-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-attribute-float.vert
> new file mode 100644
> index 0000000..33d2fd4
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-attribute-float.vert
> @@ -0,0 +1,39 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declrations of attributes are allowed.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +attribute float;
> +
> +void main()
> +{
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-const-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-const-float.vert
> new file mode 100644
> index 0000000..0500236
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-const-float.vert
> @@ -0,0 +1,39 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declarations of global const variables are allowed.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +const float;
> +
> +void main()
> +{
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-no-qualifier-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-no-qualifier-float.vert
> new file mode 100644
> index 0000000..1bf43d7
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-global-no-qualifier-float.vert
> @@ -0,0 +1,40 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declarations at global scope are allowed. This specifically
> + * tests types without type qualifiers.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +float;
> +
> +void main()
> +{
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-const-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-const-float.vert
> new file mode 100644
> index 0000000..e961c8a
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-const-float.vert
> @@ -0,0 +1,40 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declarations of const variables are allowed at function
> + * scope.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +
> +void main()
> +{
> +    const float;
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-no-qualifier-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-no-qualifier-float.vert
> new file mode 100644
> index 0000000..d24ae91
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-local-no-qualifier-float.vert
> @@ -0,0 +1,40 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declarations at function scope are allowed. This specifically
> + * tests types without type qualifiers.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +
> +void main()
> +{
> +    float;
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-uniform-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-uniform-float.vert
> new file mode 100644
> index 0000000..5e1b43f
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-uniform-float.vert
> @@ -0,0 +1,39 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty 'uniform' declarations are allowed.
> +
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +uniform float;
> +
> +void main()
> +{
> +    gl_Position = gl_Vertex;
> +}
> diff --git a/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-varying-float.vert b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-varying-float.vert
> new file mode 100644
> index 0000000..26f4d75
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/declarations/empty-declaration-varying-float.vert
> @@ -0,0 +1,39 @@
> +/*
> + * [config]
> + * glsl_version: 1.10
> + * expect_result: pass
> + * [end config]
> + * 
> + * Test that empty declrations of varyings are allowed.
> + * 
> + * The formal GLSL grammar allows empty declarations.  From page 68 (page 74 of
> + * pdf) of the GLSL 1.10 spec:
> + *     init_declarator_list:
> + *         single_declaration
> + *         ...
> + * 
> + *     single_declaration:
> + *         fully_specified_type
> + *         ...
> + * 
> + *     fully_specified_type:
> + *         type_specifier
> + *         type_qualifier type_specifier
> + * 
> + * Since this property of the grammar is consistent through all versions of GLSL
> + * (presently up to GLSL 4.10), this is unlikely to be a grammar bug.
> + * 
> + * Moreover, C99 allows empty declarations. The program below successfully
> + * compiles with `gcc --std=c99`.
> + *     float;
> + *     int main() { return 0; }
> + */
> +
> +#version 110
> +
> +varying float;
> +
> +void main()
> +{
> +    gl_Position = gl_Vertex;
> +}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk48Wq4ACgkQX1gOwKyEAw9CkgCgmFLpTmBnzvVIwJQNxSFrd621
34MAnRrYy+aImE0tKFnd9JxeiKrM6+l4
=dxmt
-----END PGP SIGNATURE-----


More information about the Piglit mailing list