Remove TIntermediate::addConstantUnion
This includes asserts in TConstantUnion to reveal incorrect usage of
union - reading a different field of an union that has last been set
is undefined behavior in C++.
Existing issues with accessing incorrect fields of constant unions
are fixed.
BUG=angleproject:1490
TEST=angle_unittests
Change-Id: Idd6b7a871d73e2928f117a9348c92043612fab82
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index 142b5db..83eba11 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -607,7 +607,7 @@
ASSERT(namedBlock);
namedBlock->staticUse = true;
- unsigned int fieldIndex = constantUnion->getUConst(0);
+ unsigned int fieldIndex = static_cast<unsigned int>(constantUnion->getIConst(0));
ASSERT(fieldIndex < namedBlock->fields.size());
namedBlock->fields[fieldIndex].staticUse = true;
return false;