--- /dev/null
+#version 130
+
+void main()
+{
+ float foo;
+ float undefined;
+
+ foo = undefined;
+}
+
--- /dev/null
+0:8(8): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ float foo;
+ float undefinedThenDefined;
+
+ foo = undefinedThenDefined;
+ undefinedThenDefined = 2.0;
+ foo = undefinedThenDefined;
+}
+
--- /dev/null
+0:8(8): warning: `undefinedThenDefined' used uninitialized
--- /dev/null
+#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;
+ }
+}
+
--- /dev/null
+0:11(18): warning: `undefined' used uninitialized
+0:15(9): warning: `undefined' used uninitialized
+0:15(21): warning: `undefined2' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int undefined;
+ int defined = 2;
+ float fooFloat;
+
+ if (undefined < 0) {
+ fooFloat = 10.0;
+ }
+
+ if (defined < 0) {
+ fooFloat = 10.0;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int undefined;
+ int defined = 2;
+ float fooFloat;
+
+ if (undefined > 0) {
+ fooFloat = 10.0;
+ }
+
+ if (defined > 0) {
+ fooFloat = 10.0;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int undefined;
+ int defined = 2;
+ float fooFloat;
+
+ if (undefined <= 0) {
+ fooFloat = 10.0;
+ }
+
+ if (defined <= 0) {
+ fooFloat = 10.0;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int undefined;
+ int defined = 2;
+ float fooFloat;
+
+ if (undefined >= 0) {
+ fooFloat = 10.0;
+ }
+
+ if (defined >= 0) {
+ fooFloat = 10.0;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
--- /dev/null
+#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;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
+0:17(6): warning: `undefined' used uninitialized
+0:21(16): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt *= undefined;
+ fooInt *= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt /= undefined;
+ fooInt /= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt += undefined;
+ fooInt += defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt -= undefined;
+ fooInt -= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int myInt;
+
+ myInt %= undefined;
+ myInt %= defined;
+}
+
--- /dev/null
+0:9(11): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt >>= undefined;
+ fooInt >>= defined;
+}
+
--- /dev/null
+0:9(13): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt <<= undefined;
+ fooInt <<= defined;
+}
+
--- /dev/null
+0:9(13): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt &= undefined;
+ fooInt &= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt |= undefined;
+ fooInt |= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#version 130
+
+void main()
+{
+ int defined = 2;
+ int undefined;
+ int fooInt;
+
+ fooInt ^= undefined;
+ fooInt ^= defined;
+}
+
--- /dev/null
+0:9(12): warning: `undefined' used uninitialized
--- /dev/null
+#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;
+ }
+}
--- /dev/null
+0:9(7): warning: `undefined' used uninitialized
+0:17(7): warning: `undefined' used uninitialized
+0:21(17): warning: `undefined' used uninitialized
--- /dev/null
+#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];
+}
+
--- /dev/null
+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
--- /dev/null
+#version 130
+
+void main()
+{
+ float array[4];
+ int fooLength;
+
+ fooLength = array.length();
+ array[0] = 2.0;
+ fooLength = array.length();
+}
+
--- /dev/null
+#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;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
+0:17(6): warning: `undefined' used uninitialized
+0:21(17): warning: `undefined' used uninitialized
--- /dev/null
+#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;
+ }
+}
+
--- /dev/null
+0:9(6): warning: `undefined' used uninitialized
+0:17(6): warning: `undefined' used uninitialized
+0:21(17): warning: `undefined' used uninitialized
--- /dev/null
+#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;
+ }
+}
+
--- /dev/null
+0:10(9): warning: `undefined' used uninitialized
+0:16(13): warning: `undefined' used uninitialized
+0:25(13): warning: `undefined' used uninitialized
--- /dev/null
+#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;
+}
+
--- /dev/null
+0:11(12): warning: `fooOut' used uninitialized
+0:12(11): warning: `undefined' used uninitialized
--- /dev/null
+#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);
+}
+
--- /dev/null
+0:14(6): warning: `undefinedFloat' used uninitialized
+0:14(31): warning: `undefinedFloat2' used uninitialized
--- /dev/null
+#version 130
+
+void fooFunction(out float outVar);
+
+out float fooOut;
+
+void main()
+{
+ float willBeDefined;
+
+ fooFunction(willBeDefined);
+ fooOut = willBeDefined;
+}
+
--- /dev/null
+#version 130
+
+void fooFunction(inout float outVar);
+
+out float fooOut;
+
+void main()
+{
+ float willBeDefined;
+
+ fooFunction(willBeDefined);
+ fooOut = willBeDefined;
+}
+
--- /dev/null
+0:11(14): warning: `willBeDefined' used uninitialized
--- /dev/null
+#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;
+}
+
--- /dev/null
+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
--- /dev/null
+#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;
+}
+
--- /dev/null
+0:13(13): warning: `fooStruct' used uninitialized
--- /dev/null
+#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]);
+}
+
--- /dev/null
+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