[Mesa-dev] [PATCH] glsl: add unit tests data vertex/expected outcome for uninitialized warning

Ian Romanick idr at freedesktop.org
Thu May 26 00:49:51 UTC 2016


This patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 05/13/2016 01:21 AM, Alejandro PiƱeiro wrote:
> v2: fix 025 test. Add three more tests (Ian Romanick)
> ---
> 
> This patch adds the two tests Ian suggested:
>   026-out-function-parameter-shaderout.ver
>   027-inout-function-parameter-shaderout.vert
> 
> Plus one combining function parameters and undefined/then defined arrays
> with undefined indexes:
>   030-array-as-function-parameter
> 
> It also updates 025 test. I have just sent a v3 of the patch 02 of this
> series, due an error detected by test 026.
> 
>  .../glsl/tests/warnings/000-basic-test.vert        | 10 ++++++++
>  .../tests/warnings/000-basic-test.vert.expected    |  1 +
>  .../warnings/001-use-undefined-then-define.vert    | 12 ++++++++++
>  .../001-use-undefined-then-define.vert.expected    |  1 +
>  src/compiler/glsl/tests/warnings/002-loop.vert     | 23 ++++++++++++++++++
>  .../glsl/tests/warnings/002-loop.vert.expected     |  3 +++
>  src/compiler/glsl/tests/warnings/003-less.vert     | 17 +++++++++++++
>  .../glsl/tests/warnings/003-less.vert.expected     |  1 +
>  src/compiler/glsl/tests/warnings/004-greater.vert  | 17 +++++++++++++
>  .../glsl/tests/warnings/004-greater.vert.expected  |  1 +
>  src/compiler/glsl/tests/warnings/005-lequal.vert   | 17 +++++++++++++
>  .../glsl/tests/warnings/005-lequal.vert.expected   |  1 +
>  src/compiler/glsl/tests/warnings/006-gequal.vert   | 17 +++++++++++++
>  .../glsl/tests/warnings/006-gequal.vert.expected   |  1 +
>  src/compiler/glsl/tests/warnings/007-test-mod.vert | 25 +++++++++++++++++++
>  .../glsl/tests/warnings/007-test-mod.vert.expected |  3 +++
>  .../glsl/tests/warnings/008-mulassign.vert         | 12 ++++++++++
>  .../tests/warnings/008-mulassign.vert.expected     |  1 +
>  .../glsl/tests/warnings/009-div-assign.vert        | 12 ++++++++++
>  .../tests/warnings/009-div-assign.vert.expected    |  1 +
>  .../glsl/tests/warnings/010-add-assign.vert        | 12 ++++++++++
>  .../tests/warnings/010-add-assign.vert.expected    |  1 +
>  .../glsl/tests/warnings/011-sub-assign.vert        | 12 ++++++++++
>  .../tests/warnings/011-sub-assign.vert.expected    |  1 +
>  .../glsl/tests/warnings/012-modassign.vert         | 12 ++++++++++
>  .../tests/warnings/012-modassign.vert.expected     |  1 +
>  src/compiler/glsl/tests/warnings/013-lsassign.vert | 12 ++++++++++
>  .../glsl/tests/warnings/013-lsassign.vert.expected |  1 +
>  src/compiler/glsl/tests/warnings/014-rsassign.vert | 12 ++++++++++
>  .../glsl/tests/warnings/014-rsassign.vert.expected |  1 +
>  .../glsl/tests/warnings/015-andassign.vert         | 12 ++++++++++
>  .../tests/warnings/015-andassign.vert.expected     |  1 +
>  src/compiler/glsl/tests/warnings/016-orassign.vert | 12 ++++++++++
>  .../glsl/tests/warnings/016-orassign.vert.expected |  1 +
>  .../glsl/tests/warnings/017-xorassign.vert         | 12 ++++++++++
>  .../tests/warnings/017-xorassign.vert.expected     |  1 +
>  src/compiler/glsl/tests/warnings/018-bitand.vert   | 24 +++++++++++++++++++
>  .../glsl/tests/warnings/018-bitand.vert.expected   |  3 +++
>  src/compiler/glsl/tests/warnings/019-array.vert    | 23 ++++++++++++++++++
>  .../glsl/tests/warnings/019-array.vert.expected    |  5 ++++
>  .../glsl/tests/warnings/020-array-length.vert      | 12 ++++++++++
>  .../tests/warnings/020-array-length.vert.expected  |  0
>  src/compiler/glsl/tests/warnings/021-lshift.vert   | 25 +++++++++++++++++++
>  .../glsl/tests/warnings/021-lshift.vert.expected   |  3 +++
>  src/compiler/glsl/tests/warnings/022-rshift.vert   | 25 +++++++++++++++++++
>  .../glsl/tests/warnings/022-rshift.vert.expected   |  3 +++
>  src/compiler/glsl/tests/warnings/023-switch.vert   | 28 ++++++++++++++++++++++
>  .../glsl/tests/warnings/023-switch.vert.expected   |  3 +++
>  .../glsl/tests/warnings/024-shaderout.vert         | 19 +++++++++++++++
>  .../tests/warnings/024-shaderout.vert.expected     |  2 ++
>  .../tests/warnings/025-function-parameters.vert    | 16 +++++++++++++
>  .../warnings/025-function-parameters.vert.expected |  2 ++
>  .../026-out-function-parameter-shaderout.vert      | 14 +++++++++++
>  ...-out-function-parameter-shaderout.vert.expected |  0
>  .../027-inout-function-parameter-shaderout.vert    | 14 +++++++++++
>  ...nout-function-parameter-shaderout.vert.expected |  1 +
>  .../glsl/tests/warnings/028-conditional.vert       | 17 +++++++++++++
>  .../tests/warnings/028-conditional.vert.expected   |  6 +++++
>  .../glsl/tests/warnings/029-fieldselection.vert    | 23 ++++++++++++++++++
>  .../warnings/029-fieldselection.vert.expected      |  1 +
>  .../warnings/030-array-as-function-parameter.vert  | 17 +++++++++++++
>  .../030-array-as-function-parameter.vert.expected  |  7 ++++++
>  62 files changed, 573 insertions(+)
>  create mode 100644 src/compiler/glsl/tests/warnings/000-basic-test.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/000-basic-test.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/002-loop.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/002-loop.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/003-less.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/003-less.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/004-greater.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/004-greater.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/005-lequal.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/005-lequal.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/006-gequal.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/006-gequal.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/007-test-mod.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/007-test-mod.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/008-mulassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/008-mulassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/009-div-assign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/009-div-assign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/010-add-assign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/010-add-assign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/011-sub-assign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/011-sub-assign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/012-modassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/012-modassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/013-lsassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/013-lsassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/014-rsassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/014-rsassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/015-andassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/015-andassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/016-orassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/016-orassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/017-xorassign.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/017-xorassign.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/018-bitand.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/018-bitand.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/019-array.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/019-array.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/020-array-length.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/020-array-length.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/021-lshift.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/021-lshift.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/022-rshift.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/022-rshift.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/023-switch.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/023-switch.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/024-shaderout.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/024-shaderout.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/025-function-parameters.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/025-function-parameters.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/028-conditional.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/028-conditional.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/029-fieldselection.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/029-fieldselection.vert.expected
>  create mode 100644 src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert
>  create mode 100644 src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert.expected
> 
> diff --git a/src/compiler/glsl/tests/warnings/000-basic-test.vert b/src/compiler/glsl/tests/warnings/000-basic-test.vert
> new file mode 100644
> index 0000000..266eed6
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/000-basic-test.vert
> @@ -0,0 +1,10 @@
> +#version 130
> +
> +void main()
> +{
> +  float foo;
> +  float undefined;
> +
> +  foo = undefined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/000-basic-test.vert.expected b/src/compiler/glsl/tests/warnings/000-basic-test.vert.expected
> new file mode 100644
> index 0000000..ed02a95
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/000-basic-test.vert.expected
> @@ -0,0 +1 @@
> +0:8(8): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert b/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert
> new file mode 100644
> index 0000000..2175afe
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  float foo;
> +  float undefinedThenDefined;
> +
> +  foo = undefinedThenDefined;
> +  undefinedThenDefined = 2.0;
> +  foo = undefinedThenDefined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert.expected b/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert.expected
> new file mode 100644
> index 0000000..a036d67
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/001-use-undefined-then-define.vert.expected
> @@ -0,0 +1 @@
> +0:8(8): warning: `undefinedThenDefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/002-loop.vert b/src/compiler/glsl/tests/warnings/002-loop.vert
> new file mode 100644
> index 0000000..de05d9c
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/002-loop.vert
> @@ -0,0 +1,23 @@
> +#version 130
> +
> +void main()
> +{
> +   int i;
> +   int undefined;
> +   int undefined2;
> +   int defined = 2;
> +   float fooFloat;
> +
> +   for (i = 0; i < undefined; i++) {
> +      fooFloat = 10.0;
> +   }
> +
> +   for (; undefined < undefined2; i++) {
> +      fooFloat = 10.0;
> +   }
> +
> +   for (i = 0; i < defined; i++) {
> +      fooFloat = 10.0;
> +   }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/002-loop.vert.expected b/src/compiler/glsl/tests/warnings/002-loop.vert.expected
> new file mode 100644
> index 0000000..7a51001
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/002-loop.vert.expected
> @@ -0,0 +1,3 @@
> +0:11(18): warning: `undefined' used uninitialized
> +0:15(9): warning: `undefined' used uninitialized
> +0:15(21): warning: `undefined2' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/003-less.vert b/src/compiler/glsl/tests/warnings/003-less.vert
> new file mode 100644
> index 0000000..bbab55a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/003-less.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void main()
> +{
> +   int undefined;
> +   int defined = 2;
> +   float fooFloat;
> +
> +   if (undefined < 0) {
> +      fooFloat = 10.0;
> +   }
> +
> +   if (defined < 0) {
> +      fooFloat = 10.0;
> +   }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/003-less.vert.expected b/src/compiler/glsl/tests/warnings/003-less.vert.expected
> new file mode 100644
> index 0000000..93cd789
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/003-less.vert.expected
> @@ -0,0 +1 @@
> +0:9(6): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/004-greater.vert b/src/compiler/glsl/tests/warnings/004-greater.vert
> new file mode 100644
> index 0000000..c9842e5
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/004-greater.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void main()
> +{
> +   int undefined;
> +   int defined = 2;
> +   float fooFloat;
> +
> +   if (undefined > 0) {
> +      fooFloat = 10.0;
> +   }
> +
> +   if (defined > 0) {
> +      fooFloat = 10.0;
> +   }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/004-greater.vert.expected b/src/compiler/glsl/tests/warnings/004-greater.vert.expected
> new file mode 100644
> index 0000000..93cd789
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/004-greater.vert.expected
> @@ -0,0 +1 @@
> +0:9(6): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/005-lequal.vert b/src/compiler/glsl/tests/warnings/005-lequal.vert
> new file mode 100644
> index 0000000..73e476a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/005-lequal.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void main()
> +{
> +   int undefined;
> +   int defined = 2;
> +   float fooFloat;
> +
> +   if (undefined <= 0) {
> +      fooFloat = 10.0;
> +   }
> +
> +   if (defined <= 0) {
> +      fooFloat = 10.0;
> +   }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/005-lequal.vert.expected b/src/compiler/glsl/tests/warnings/005-lequal.vert.expected
> new file mode 100644
> index 0000000..93cd789
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/005-lequal.vert.expected
> @@ -0,0 +1 @@
> +0:9(6): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/006-gequal.vert b/src/compiler/glsl/tests/warnings/006-gequal.vert
> new file mode 100644
> index 0000000..f1694bd
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/006-gequal.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void main()
> +{
> +   int undefined;
> +   int defined = 2;
> +   float fooFloat;
> +
> +   if (undefined >= 0) {
> +      fooFloat = 10.0;
> +   }
> +
> +   if (defined >= 0) {
> +      fooFloat = 10.0;
> +   }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/006-gequal.vert.expected b/src/compiler/glsl/tests/warnings/006-gequal.vert.expected
> new file mode 100644
> index 0000000..93cd789
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/006-gequal.vert.expected
> @@ -0,0 +1 @@
> +0:9(6): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/007-test-mod.vert b/src/compiler/glsl/tests/warnings/007-test-mod.vert
> new file mode 100644
> index 0000000..2881db8
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/007-test-mod.vert
> @@ -0,0 +1,25 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  float fooFloat;
> +
> +  if (undefined % 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined % 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (undefined % defined == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined % undefined == 0) {
> +    fooFloat = 10.0;
> +  }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/007-test-mod.vert.expected b/src/compiler/glsl/tests/warnings/007-test-mod.vert.expected
> new file mode 100644
> index 0000000..78613d5
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/007-test-mod.vert.expected
> @@ -0,0 +1,3 @@
> +0:9(6): warning: `undefined' used uninitialized
> +0:17(6): warning: `undefined' used uninitialized
> +0:21(16): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/008-mulassign.vert b/src/compiler/glsl/tests/warnings/008-mulassign.vert
> new file mode 100644
> index 0000000..0923891
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/008-mulassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt *= undefined;
> +  fooInt *= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/008-mulassign.vert.expected b/src/compiler/glsl/tests/warnings/008-mulassign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/008-mulassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/009-div-assign.vert b/src/compiler/glsl/tests/warnings/009-div-assign.vert
> new file mode 100644
> index 0000000..91440bf
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/009-div-assign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt /= undefined;
> +  fooInt /= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/009-div-assign.vert.expected b/src/compiler/glsl/tests/warnings/009-div-assign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/009-div-assign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/010-add-assign.vert b/src/compiler/glsl/tests/warnings/010-add-assign.vert
> new file mode 100644
> index 0000000..661219f
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/010-add-assign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt += undefined;
> +  fooInt += defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/010-add-assign.vert.expected b/src/compiler/glsl/tests/warnings/010-add-assign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/010-add-assign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/011-sub-assign.vert b/src/compiler/glsl/tests/warnings/011-sub-assign.vert
> new file mode 100644
> index 0000000..9839dec
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/011-sub-assign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt -= undefined;
> +  fooInt -= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/011-sub-assign.vert.expected b/src/compiler/glsl/tests/warnings/011-sub-assign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/011-sub-assign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/012-modassign.vert b/src/compiler/glsl/tests/warnings/012-modassign.vert
> new file mode 100644
> index 0000000..2f261a3
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/012-modassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int myInt;
> +
> +  myInt %= undefined;
> +  myInt %= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/012-modassign.vert.expected b/src/compiler/glsl/tests/warnings/012-modassign.vert.expected
> new file mode 100644
> index 0000000..637142e
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/012-modassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(11): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/013-lsassign.vert b/src/compiler/glsl/tests/warnings/013-lsassign.vert
> new file mode 100644
> index 0000000..f2b49e2
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/013-lsassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt >>= undefined;
> +  fooInt >>= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/013-lsassign.vert.expected b/src/compiler/glsl/tests/warnings/013-lsassign.vert.expected
> new file mode 100644
> index 0000000..b20d3c0
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/013-lsassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(13): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/014-rsassign.vert b/src/compiler/glsl/tests/warnings/014-rsassign.vert
> new file mode 100644
> index 0000000..798b6cc
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/014-rsassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt <<= undefined;
> +  fooInt <<= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/014-rsassign.vert.expected b/src/compiler/glsl/tests/warnings/014-rsassign.vert.expected
> new file mode 100644
> index 0000000..b20d3c0
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/014-rsassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(13): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/015-andassign.vert b/src/compiler/glsl/tests/warnings/015-andassign.vert
> new file mode 100644
> index 0000000..a86a8d8
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/015-andassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt &= undefined;
> +  fooInt &= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/015-andassign.vert.expected b/src/compiler/glsl/tests/warnings/015-andassign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/015-andassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/016-orassign.vert b/src/compiler/glsl/tests/warnings/016-orassign.vert
> new file mode 100644
> index 0000000..c04241a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/016-orassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt |= undefined;
> +  fooInt |= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/016-orassign.vert.expected b/src/compiler/glsl/tests/warnings/016-orassign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/016-orassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/017-xorassign.vert b/src/compiler/glsl/tests/warnings/017-xorassign.vert
> new file mode 100644
> index 0000000..ff649f7
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/017-xorassign.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  fooInt ^= undefined;
> +  fooInt ^= defined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/017-xorassign.vert.expected b/src/compiler/glsl/tests/warnings/017-xorassign.vert.expected
> new file mode 100644
> index 0000000..8fbb408
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/017-xorassign.vert.expected
> @@ -0,0 +1 @@
> +0:9(12): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/018-bitand.vert b/src/compiler/glsl/tests/warnings/018-bitand.vert
> new file mode 100644
> index 0000000..7e879dc
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/018-bitand.vert
> @@ -0,0 +1,24 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  float fooFloat;
> +
> +  if ((undefined | 2) == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if ((defined | 2) == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if ((undefined | defined) == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if ((defined | undefined) == 0) {
> +    fooFloat = 10.0;
> +  }
> +}
> diff --git a/src/compiler/glsl/tests/warnings/018-bitand.vert.expected b/src/compiler/glsl/tests/warnings/018-bitand.vert.expected
> new file mode 100644
> index 0000000..c7e5c99
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/018-bitand.vert.expected
> @@ -0,0 +1,3 @@
> +0:9(7): warning: `undefined' used uninitialized
> +0:17(7): warning: `undefined' used uninitialized
> +0:21(17): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/019-array.vert b/src/compiler/glsl/tests/warnings/019-array.vert
> new file mode 100644
> index 0000000..43d7f4c
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/019-array.vert
> @@ -0,0 +1,23 @@
> +#version 130
> +
> +void main()
> +{
> +  int undefinedIndex;
> +  int undefinedIndex2;
> +  int definedIndex = 2;
> +  int definedIndex2 = 2;
> +  float array[4];
> +  float fooPos;
> +  int fooLength;
> +
> +  fooPos = array[undefinedIndex];
> +  fooPos = array[definedIndex];
> +
> +  fooPos = array[definedIndex+definedIndex2];
> +  fooPos = array[undefinedIndex+undefinedIndex2];
> +  array[0] = 10.0;
> +  fooPos = array[definedIndex];
> +
> +  array[undefinedIndex2] = array[undefinedIndex];
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/019-array.vert.expected b/src/compiler/glsl/tests/warnings/019-array.vert.expected
> new file mode 100644
> index 0000000..3d80306
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/019-array.vert.expected
> @@ -0,0 +1,5 @@
> +0:13(17): warning: `undefinedIndex' used uninitialized
> +0:17(17): warning: `undefinedIndex' used uninitialized
> +0:17(32): warning: `undefinedIndex2' used uninitialized
> +0:21(8): warning: `undefinedIndex2' used uninitialized
> +0:21(33): warning: `undefinedIndex' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/020-array-length.vert b/src/compiler/glsl/tests/warnings/020-array-length.vert
> new file mode 100644
> index 0000000..0fa57b2
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/020-array-length.vert
> @@ -0,0 +1,12 @@
> +#version 130
> +
> +void main()
> +{
> +  float array[4];
> +  int fooLength;
> +
> +  fooLength = array.length();
> +  array[0] = 2.0;
> +  fooLength = array.length();
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/020-array-length.vert.expected b/src/compiler/glsl/tests/warnings/020-array-length.vert.expected
> new file mode 100644
> index 0000000..e69de29
> diff --git a/src/compiler/glsl/tests/warnings/021-lshift.vert b/src/compiler/glsl/tests/warnings/021-lshift.vert
> new file mode 100644
> index 0000000..ed8c819
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/021-lshift.vert
> @@ -0,0 +1,25 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  float fooFloat;
> +
> +  if (undefined << 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined << 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (undefined << defined == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined << undefined == 0) {
> +    fooFloat = 10.0;
> +  }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/021-lshift.vert.expected b/src/compiler/glsl/tests/warnings/021-lshift.vert.expected
> new file mode 100644
> index 0000000..5813f12
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/021-lshift.vert.expected
> @@ -0,0 +1,3 @@
> +0:9(6): warning: `undefined' used uninitialized
> +0:17(6): warning: `undefined' used uninitialized
> +0:21(17): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/022-rshift.vert b/src/compiler/glsl/tests/warnings/022-rshift.vert
> new file mode 100644
> index 0000000..226d346
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/022-rshift.vert
> @@ -0,0 +1,25 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  float fooFloat;
> +
> +  if (undefined >> 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined >> 2 == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (undefined >> defined == 0) {
> +    fooFloat = 10.0;
> +  }
> +
> +  if (defined >> undefined == 0) {
> +    fooFloat = 10.0;
> +  }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/022-rshift.vert.expected b/src/compiler/glsl/tests/warnings/022-rshift.vert.expected
> new file mode 100644
> index 0000000..5813f12
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/022-rshift.vert.expected
> @@ -0,0 +1,3 @@
> +0:9(6): warning: `undefined' used uninitialized
> +0:17(6): warning: `undefined' used uninitialized
> +0:21(17): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/023-switch.vert b/src/compiler/glsl/tests/warnings/023-switch.vert
> new file mode 100644
> index 0000000..4527971
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/023-switch.vert
> @@ -0,0 +1,28 @@
> +#version 130
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  float fooFloat;
> +  int fooInt;
> +
> +  switch(undefined) {
> +  case 0:
> +    fooFloat = 0.0;
> +  case 1:
> +    fooFloat = 1.0;
> +  default:
> +    fooFloat = undefined;
> +  }
> +
> +  switch(defined) {
> +  case 0:
> +    fooFloat = 0.0;
> +  case 1:
> +    fooFloat = 1.0;
> +  default:
> +    fooFloat = undefined;
> +  }
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/023-switch.vert.expected b/src/compiler/glsl/tests/warnings/023-switch.vert.expected
> new file mode 100644
> index 0000000..201d0a2
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/023-switch.vert.expected
> @@ -0,0 +1,3 @@
> +0:10(9): warning: `undefined' used uninitialized
> +0:16(13): warning: `undefined' used uninitialized
> +0:25(13): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/024-shaderout.vert b/src/compiler/glsl/tests/warnings/024-shaderout.vert
> new file mode 100644
> index 0000000..00a7988
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/024-shaderout.vert
> @@ -0,0 +1,19 @@
> +#version 130
> +
> +out int fooOut;
> +
> +void main()
> +{
> +  int defined = 2;
> +  int undefined;
> +  int fooInt;
> +
> +  defined = fooOut;
> +  fooOut = undefined;
> +  /* Technically at this point fooOut is still undefined. But it was
> +   * initialized that is what the unitialized warning detects in any
> +   * case. "Real undefined" is beyond the scope of what mesa is/should
> +   * detect*/
> +  defined = fooOut;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/024-shaderout.vert.expected b/src/compiler/glsl/tests/warnings/024-shaderout.vert.expected
> new file mode 100644
> index 0000000..c85c55a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/024-shaderout.vert.expected
> @@ -0,0 +1,2 @@
> +0:11(12): warning: `fooOut' used uninitialized
> +0:12(11): warning: `undefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/025-function-parameters.vert b/src/compiler/glsl/tests/warnings/025-function-parameters.vert
> new file mode 100644
> index 0000000..0b7f7e5
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/025-function-parameters.vert
> @@ -0,0 +1,16 @@
> +#version 130
> +
> +void foo(float normalVar, out float outVar, inout float inoutVar)
> +{
> +  outVar = 1.0f;
> +}
> +
> +void main()
> +{
> +   float undefinedFloat;
> +   float noRaise;
> +   float undefinedFloat2;
> +
> +   foo(undefinedFloat, noRaise, undefinedFloat2);
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/025-function-parameters.vert.expected b/src/compiler/glsl/tests/warnings/025-function-parameters.vert.expected
> new file mode 100644
> index 0000000..eb06585
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/025-function-parameters.vert.expected
> @@ -0,0 +1,2 @@
> +0:14(6): warning: `undefinedFloat' used uninitialized
> +0:14(31): warning: `undefinedFloat2' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert b/src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert
> new file mode 100644
> index 0000000..4d7a44f
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert
> @@ -0,0 +1,14 @@
> +#version 130
> +
> +void fooFunction(out float outVar);
> +
> +out float fooOut;
> +
> +void main()
> +{
> +   float willBeDefined;
> +
> +   fooFunction(willBeDefined);
> +   fooOut = willBeDefined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert.expected b/src/compiler/glsl/tests/warnings/026-out-function-parameter-shaderout.vert.expected
> new file mode 100644
> index 0000000..e69de29
> diff --git a/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert b/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert
> new file mode 100644
> index 0000000..57ca755
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert
> @@ -0,0 +1,14 @@
> +#version 130
> +
> +void fooFunction(inout float outVar);
> +
> +out float fooOut;
> +
> +void main()
> +{
> +   float willBeDefined;
> +
> +   fooFunction(willBeDefined);
> +   fooOut = willBeDefined;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert.expected b/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert.expected
> new file mode 100644
> index 0000000..1724975
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/027-inout-function-parameter-shaderout.vert.expected
> @@ -0,0 +1 @@
> +0:11(14): warning: `willBeDefined' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/028-conditional.vert b/src/compiler/glsl/tests/warnings/028-conditional.vert
> new file mode 100644
> index 0000000..3447f05
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/028-conditional.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void main()
> +{
> +  bool defined = false;
> +  bool undefined;
> +  int fooInt;
> +  int definedInt = 2;
> +  int undefinedInt;
> +
> +  fooInt = defined ? definedInt : undefinedInt;
> +  fooInt = defined ? undefinedInt : definedInt;
> +
> +  fooInt = undefined ? definedInt : undefinedInt;
> +  fooInt = undefined ? undefinedInt : definedInt;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/028-conditional.vert.expected b/src/compiler/glsl/tests/warnings/028-conditional.vert.expected
> new file mode 100644
> index 0000000..aaf5b7b
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/028-conditional.vert.expected
> @@ -0,0 +1,6 @@
> +0:11(34): warning: `undefinedInt' used uninitialized
> +0:12(21): warning: `undefinedInt' used uninitialized
> +0:14(11): warning: `undefined' used uninitialized
> +0:14(36): warning: `undefinedInt' used uninitialized
> +0:15(11): warning: `undefined' used uninitialized
> +0:15(23): warning: `undefinedInt' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/029-fieldselection.vert b/src/compiler/glsl/tests/warnings/029-fieldselection.vert
> new file mode 100644
> index 0000000..cdec06a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/029-fieldselection.vert
> @@ -0,0 +1,23 @@
> +#version 130
> +
> +struct s {
> +  float c;
> +  float x;
> +};
> +
> +void main()
> +{
> +  float fooFloat;
> +  s fooStruct;
> +
> +  fooFloat = fooStruct.c;
> +  fooStruct.c = 10.0;
> +  fooFloat = fooStruct.c;
> +  fooStruct.c = 20.0;
> +
> +  /* Technically .x is also uninitialized, but detecting this is beyond
> +   * scope. FWIW, gcc doesn't detect this neither.
> +   */
> +  fooFloat = fooStruct.x;
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/029-fieldselection.vert.expected b/src/compiler/glsl/tests/warnings/029-fieldselection.vert.expected
> new file mode 100644
> index 0000000..0a2c04a
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/029-fieldselection.vert.expected
> @@ -0,0 +1 @@
> +0:13(13): warning: `fooStruct' used uninitialized
> diff --git a/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert b/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert
> new file mode 100644
> index 0000000..8689f07
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert
> @@ -0,0 +1,17 @@
> +#version 130
> +
> +void foo(float normalVar, out float outVar, inout float inoutVar);
> +
> +void main()
> +{
> +   int undefinedIndex;
> +   int definedIndex = 2;
> +   float willBeDefined[4];
> +
> +   foo(willBeDefined[undefinedIndex], willBeDefined[undefinedIndex], willBeDefined[undefinedIndex]);
> +   foo(willBeDefined[definedIndex], willBeDefined[definedIndex], willBeDefined[definedIndex]);
> +   willBeDefined[0] = 10.0;
> +   foo(willBeDefined[undefinedIndex], willBeDefined[undefinedIndex], willBeDefined[undefinedIndex]);
> +   foo(willBeDefined[definedIndex], willBeDefined[definedIndex], willBeDefined[definedIndex]);
> +}
> +
> diff --git a/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert.expected b/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert.expected
> new file mode 100644
> index 0000000..21cb2c5
> --- /dev/null
> +++ b/src/compiler/glsl/tests/warnings/030-array-as-function-parameter.vert.expected
> @@ -0,0 +1,7 @@
> +0:11(20): warning: `undefinedIndex' used uninitialized
> +0:11(51): warning: `undefinedIndex' used uninitialized
> +0:11(82): warning: `undefinedIndex' used uninitialized
> +0:11(6): warning: `willBeDefined' used uninitialized
> +0:14(20): warning: `undefinedIndex' used uninitialized
> +0:14(51): warning: `undefinedIndex' used uninitialized
> +0:14(82): warning: `undefinedIndex' used uninitialized
> 



More information about the mesa-dev mailing list