diff options
author | Mika Väinölä <mika.vainola@siru.fi> | 2019-04-09 16:28:45 +0300 |
---|---|---|
committer | Alexander Galazin <Alexander.Galazin@arm.com> | 2019-05-08 12:15:05 -0400 |
commit | 31dd7a0b3c38181ebdaf10bdc95f8c591734c342 (patch) | |
tree | 48bfaf4c94ade314c6222f2560d8aca5bf030246 | |
parent | 5f3c4318fb9ff29428d25661f2661364233a6c99 (diff) | |
download | VK-GL-CTS-31dd7a0b3c38181ebdaf10bdc95f8c591734c342.tar.gz VK-GL-CTS-31dd7a0b3c38181ebdaf10bdc95f8c591734c342.tar.bz2 VK-GL-CTS-31dd7a0b3c38181ebdaf10bdc95f8c591734c342.zip |
Fix Clang 8 and GCC 9 warnings
Rename some TYPE_LAST and STATE_LAST enums that produce variable
shadowing warnings with Clang 8. Reimplement tcu::Format::Hex methods
using stringstream and IO manipulators instead of format strings
and add a cast to deUint32 to fix warnings on GCC 9.
Component: Framework
VK-GL-CTS issue: 1631
Change-Id: Ide4b25c106810b725c5ed7caaaf676f02e81b368
-rw-r--r-- | executor/tools/xeExtractValues.cpp | 2 | ||||
-rw-r--r-- | executor/xeTestCaseResult.cpp | 6 | ||||
-rw-r--r-- | executor/xeTestCaseResult.hpp | 18 | ||||
-rw-r--r-- | external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp | 2 | ||||
-rw-r--r-- | framework/common/tcuFormatUtil.hpp | 22 | ||||
-rw-r--r-- | framework/common/tcuTestHierarchyIterator.cpp | 24 | ||||
-rw-r--r-- | framework/common/tcuTestHierarchyIterator.hpp | 16 | ||||
-rw-r--r-- | framework/opengl/gluDrawUtil.cpp | 10 | ||||
-rw-r--r-- | framework/opengl/gluDrawUtil.hpp | 12 | ||||
-rw-r--r-- | framework/opengl/gluVarType.cpp | 28 | ||||
-rw-r--r-- | framework/opengl/gluVarType.hpp | 14 | ||||
-rw-r--r-- | framework/opengl/gluVarTypeUtil.hpp | 4 | ||||
-rw-r--r-- | modules/glshared/glsFragOpInteractionCase.cpp | 2 |
13 files changed, 82 insertions, 78 deletions
diff --git a/executor/tools/xeExtractValues.cpp b/executor/tools/xeExtractValues.cpp index 64a8689d7..5949824a2 100644 --- a/executor/tools/xeExtractValues.cpp +++ b/executor/tools/xeExtractValues.cpp @@ -110,7 +110,7 @@ static Value findValueByTag (const xe::ri::List& items, const string& tagName) if (item.getType() == xe::ri::TYPE_SECTION) { const Value value = findValueByTag(static_cast<const xe::ri::Section&>(item).items, tagName); - if (value.getType() != Value::TYPE_EMPTY) + if (value.getType() != Value::NUMVALTYPE_EMPTY) return value; } else if (item.getType() == xe::ri::TYPE_NUMBER) diff --git a/executor/xeTestCaseResult.cpp b/executor/xeTestCaseResult.cpp index f007603a2..5e56fa4f0 100644 --- a/executor/xeTestCaseResult.cpp +++ b/executor/xeTestCaseResult.cpp @@ -71,14 +71,14 @@ std::ostream& operator<< (std::ostream& str, const NumericValue& value) { switch (value.getType()) { - case NumericValue::TYPE_FLOAT64: + case NumericValue::NUMVALTYPE_FLOAT64: return str << std::setprecision(std::numeric_limits<double>::digits10 + 2) << value.getFloat64(); - case NumericValue::TYPE_INT64: + case NumericValue::NUMVALTYPE_INT64: return str << value.getInt64(); default: - DE_ASSERT(value.getType() == NumericValue::TYPE_EMPTY); + DE_ASSERT(value.getType() == NumericValue::NUMVALTYPE_EMPTY); return str; } } diff --git a/executor/xeTestCaseResult.hpp b/executor/xeTestCaseResult.hpp index 11d68ce8e..eef92d79d 100644 --- a/executor/xeTestCaseResult.hpp +++ b/executor/xeTestCaseResult.hpp @@ -163,20 +163,20 @@ class NumericValue public: enum Type { - TYPE_EMPTY = 0, - TYPE_INT64, - TYPE_FLOAT64, + NUMVALTYPE_EMPTY = 0, + NUMVALTYPE_INT64, + NUMVALTYPE_FLOAT64, - TYPE_LAST + NUMVALTYPE_LAST }; - NumericValue (void) : m_type(TYPE_EMPTY) {} - NumericValue (deInt64 value) : m_type(TYPE_INT64) { m_value.int64 = value; } - NumericValue (double value) : m_type(TYPE_FLOAT64) { m_value.float64 = value; } + NumericValue (void) : m_type(NUMVALTYPE_EMPTY) {} + NumericValue (deInt64 value) : m_type(NUMVALTYPE_INT64) { m_value.int64 = value; } + NumericValue (double value) : m_type(NUMVALTYPE_FLOAT64) { m_value.float64 = value; } Type getType (void) const { return m_type; } - deInt64 getInt64 (void) const { DE_ASSERT(getType() == TYPE_INT64); return m_value.int64; } - double getFloat64 (void) const { DE_ASSERT(getType() == TYPE_FLOAT64); return m_value.float64; } + deInt64 getInt64 (void) const { DE_ASSERT(getType() == NUMVALTYPE_INT64); return m_value.int64; } + double getFloat64 (void) const { DE_ASSERT(getType() == NUMVALTYPE_FLOAT64); return m_value.float64; } private: Type m_type; diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp index 9d6a38fbb..c0a0d416d 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp @@ -1103,7 +1103,7 @@ void addGraphicsImageSamplerTest (tcu::TestCaseGroup* group) getDefaultColors(defaultColors); - const map<string, string> fragments = generateGraphicsImageSamplerSource((ReadOp)opNdx, (DescriptorType)descNdx, (TestType)testNdx, DEPTH_PROPERTY_NON_DEPTH, (deUint32)resources.inputs.size(), (formatIndex + 1) % optypeimageFormatMismatchFormatCount); + const map<string, string> fragments = generateGraphicsImageSamplerSource((ReadOp)opNdx, (DescriptorType)descNdx, (TestType)testNdx, DEPTH_PROPERTY_NON_DEPTH, (deUint32)resources.inputs.size(), (deUint32)((formatIndex + 1) % optypeimageFormatMismatchFormatCount)); // If testing for mismatched optypeimage, ignore the rendered // result (we're only interested to see if we crash) diff --git a/framework/common/tcuFormatUtil.hpp b/framework/common/tcuFormatUtil.hpp index a45c728f5..df7401298 100644 --- a/framework/common/tcuFormatUtil.hpp +++ b/framework/common/tcuFormatUtil.hpp @@ -28,6 +28,8 @@ #include <ostream> #include <string> +#include <sstream> +#include <iomanip> namespace tcu { @@ -43,20 +45,22 @@ public: std::ostream& toStream (std::ostream& stream) const { - return stream << this->toString(); + DE_STATIC_ASSERT(0 < NumDigits && NumDigits <= 16); + + return stream << "0x" + << std::right + << std::setfill('0') + << std::setw(NumDigits) + << std::hex + << value; } std::string toString (void) const { - DE_STATIC_ASSERT(0 < NumDigits && NumDigits <= 16); - - const char longFmt[] = {'0', 'x', '%', '0', '0' + NumDigits/10, '0' + NumDigits%10, 'l', 'l', 'x', 0}; - const char shortFmt[] = {'0', 'x', '%', '0', '0' + NumDigits, 'l', 'l', 'x', 0}; - - char buf[sizeof(deUint64)*2 + 3]; - deSprintf(buf, sizeof(buf), NumDigits > 9 ? longFmt : shortFmt, value); + std::stringstream stream; - return std::string(buf); + toStream(stream); + return stream.str(); } private: diff --git a/framework/common/tcuTestHierarchyIterator.cpp b/framework/common/tcuTestHierarchyIterator.cpp index 3a72b1d80..51fdf4eab 100644 --- a/framework/common/tcuTestHierarchyIterator.cpp +++ b/framework/common/tcuTestHierarchyIterator.cpp @@ -93,7 +93,7 @@ TestHierarchyIterator::TestHierarchyIterator (TestPackageRoot& rootNode, { // Init traverse state and "seek" to first reportable node. NodeIter iter(&rootNode); - iter.setState(NodeIter::STATE_ENTER); // Root is never reported + iter.setState(NodeIter::NISTATE_ENTER); // Root is never reported m_sessionStack.push_back(iter); next(); } @@ -123,10 +123,10 @@ TestHierarchyIterator::State TestHierarchyIterator::getState (void) const { const NodeIter& iter = m_sessionStack.back(); - DE_ASSERT(iter.getState() == NodeIter::STATE_ENTER || - iter.getState() == NodeIter::STATE_LEAVE); + DE_ASSERT(iter.getState() == NodeIter::NISTATE_ENTER || + iter.getState() == NodeIter::NISTATE_LEAVE); - return iter.getState() == NodeIter::STATE_ENTER ? STATE_ENTER_NODE : STATE_LEAVE_NODE; + return iter.getState() == NodeIter::NISTATE_ENTER ? STATE_ENTER_NODE : STATE_LEAVE_NODE; } else return STATE_FINISHED; @@ -167,7 +167,7 @@ void TestHierarchyIterator::next (void) switch (iter.getState()) { - case NodeIter::STATE_INIT: + case NodeIter::NISTATE_INIT: { const std::string nodePath = buildNodePath(m_sessionStack); @@ -179,20 +179,20 @@ void TestHierarchyIterator::next (void) } m_nodePath = nodePath; - iter.setState(NodeIter::STATE_ENTER); + iter.setState(NodeIter::NISTATE_ENTER); return; // Yield enter event } - case NodeIter::STATE_ENTER: + case NodeIter::NISTATE_ENTER: { if (isLeaf) { - iter.setState(NodeIter::STATE_LEAVE); + iter.setState(NodeIter::NISTATE_LEAVE); return; // Yield leave event } else { - iter.setState(NodeIter::STATE_TRAVERSE_CHILDREN); + iter.setState(NodeIter::NISTATE_TRAVERSE_CHILDREN); iter.children.clear(); switch (node->getNodeType()) @@ -208,7 +208,7 @@ void TestHierarchyIterator::next (void) break; } - case NodeIter::STATE_TRAVERSE_CHILDREN: + case NodeIter::NISTATE_TRAVERSE_CHILDREN: { int numChildren = (int)iter.children.size(); if (++iter.curChildNdx < numChildren) @@ -219,7 +219,7 @@ void TestHierarchyIterator::next (void) } else { - iter.setState(NodeIter::STATE_LEAVE); + iter.setState(NodeIter::NISTATE_LEAVE); if (node->getNodeType() != NODETYPE_ROOT) return; // Yield leave event } @@ -227,7 +227,7 @@ void TestHierarchyIterator::next (void) break; } - case NodeIter::STATE_LEAVE: + case NodeIter::NISTATE_LEAVE: { // Leave node. if (!isLeaf) diff --git a/framework/common/tcuTestHierarchyIterator.hpp b/framework/common/tcuTestHierarchyIterator.hpp index 395f8e2de..b138cbad0 100644 --- a/framework/common/tcuTestHierarchyIterator.hpp +++ b/framework/common/tcuTestHierarchyIterator.hpp @@ -131,25 +131,25 @@ private: { enum State { - STATE_INIT = 0, - STATE_ENTER, - STATE_TRAVERSE_CHILDREN, - STATE_LEAVE, + NISTATE_INIT = 0, + NISTATE_ENTER, + NISTATE_TRAVERSE_CHILDREN, + NISTATE_LEAVE, - STATE_LAST + NISTATE_LAST }; NodeIter (void) : node (DE_NULL) , curChildNdx (-1) - , m_state (STATE_LAST) + , m_state (NISTATE_LAST) { } NodeIter (TestNode* node_) : node (node_) , curChildNdx (-1) - , m_state (STATE_INIT) + , m_state (NISTATE_INIT) { } @@ -162,7 +162,7 @@ private: { switch (newState) { - case STATE_TRAVERSE_CHILDREN: + case NISTATE_TRAVERSE_CHILDREN: curChildNdx = -1; break; diff --git a/framework/opengl/gluDrawUtil.cpp b/framework/opengl/gluDrawUtil.cpp index a97f9a8d4..0cdc5012f 100644 --- a/framework/opengl/gluDrawUtil.cpp +++ b/framework/opengl/gluDrawUtil.cpp @@ -222,7 +222,7 @@ static OutputIter namedBindingsToProgramLocations (const glw::Functions& gl, deU for (InputIter cur = first; cur != end; ++cur) { const BindingPoint& binding = cur->binding; - if (binding.type == BindingPoint::TYPE_NAME) + if (binding.type == BindingPoint::BPTYPE_NAME) { DE_ASSERT(binding.location >= 0); int location = gl.getAttribLocation(program, binding.name.c_str()); @@ -258,7 +258,7 @@ static bool areVertexArrayLocationsValid (BindingIter first, BindingIter end) { const BindingPoint& binding = cur->binding; - if (binding.type != BindingPoint::TYPE_LOCATION) + if (binding.type != BindingPoint::BPTYPE_LOCATION) return false; if (usedLocations.find(binding.location) != usedLocations.end()) @@ -279,7 +279,7 @@ static void appendAttributeNonStrided (VertexBufferLayout& layout, const VertexA const int size = elementSize*va.pointer.numElements; // Must be assigned to location at this point. - DE_ASSERT(va.binding.type == BindingPoint::TYPE_LOCATION); + DE_ASSERT(va.binding.type == BindingPoint::BPTYPE_LOCATION); layout.attributes.push_back(VertexAttributeDescriptor(va.binding.location, va.pointer.componentType, @@ -388,7 +388,7 @@ IndexBuffer::~IndexBuffer (void) static inline VertexAttributeDescriptor getUserPointerDescriptor (const VertexArrayBinding& vertexArray) { - DE_ASSERT(vertexArray.binding.type == BindingPoint::TYPE_LOCATION); + DE_ASSERT(vertexArray.binding.type == BindingPoint::BPTYPE_LOCATION); return VertexAttributeDescriptor(vertexArray.binding.location, vertexArray.pointer.componentType, @@ -433,7 +433,7 @@ static void disableVertexArrays (const glw::Functions& gl, const std::vector<Ver { for (std::vector<VertexArrayBinding>::const_iterator vaIter = bindings.begin(); vaIter != bindings.end(); ++vaIter) { - DE_ASSERT(vaIter->binding.type == BindingPoint::TYPE_LOCATION); + DE_ASSERT(vaIter->binding.type == BindingPoint::BPTYPE_LOCATION); gl.disableVertexAttribArray(vaIter->binding.location); } } diff --git a/framework/opengl/gluDrawUtil.hpp b/framework/opengl/gluDrawUtil.hpp index 7108b7e2c..7933a7083 100644 --- a/framework/opengl/gluDrawUtil.hpp +++ b/framework/opengl/gluDrawUtil.hpp @@ -94,19 +94,19 @@ struct BindingPoint { enum Type { - TYPE_LOCATION = 0, //!< Binding by numeric location. - TYPE_NAME, //!< Binding by input name. + BPTYPE_LOCATION = 0, //!< Binding by numeric location. + BPTYPE_NAME, //!< Binding by input name. - TYPE_LAST + BPTYPE_LAST }; Type type; //!< Binding type (name or location). std::string name; //!< Input name, or empty if is not binding by name. int location; //!< Input location, or offset to named location if binding by name. - BindingPoint (void) : type(TYPE_LAST), location (0) {} - explicit BindingPoint (int location_) : type(TYPE_LOCATION), location(location_) {} - explicit BindingPoint (const std::string& name_, int location_ = 0) : type(TYPE_NAME), name(name_), location(location_) {} + BindingPoint (void) : type(BPTYPE_LAST), location (0) {} + explicit BindingPoint (int location_) : type(BPTYPE_LOCATION), location(location_) {} + explicit BindingPoint (const std::string& name_, int location_ = 0) : type(BPTYPE_NAME), name(name_), location(location_) {} }; struct VertexArrayPointer diff --git a/framework/opengl/gluVarType.cpp b/framework/opengl/gluVarType.cpp index fcb2c9c9f..0050432b4 100644 --- a/framework/opengl/gluVarType.cpp +++ b/framework/opengl/gluVarType.cpp @@ -29,25 +29,25 @@ namespace glu { VarType::VarType (void) - : m_type(TYPE_LAST) + : m_type(VARTYPE_LAST) { } VarType::VarType (const VarType& other) - : m_type(TYPE_LAST) + : m_type(VARTYPE_LAST) { *this = other; } VarType::VarType (DataType basicType, Precision precision) - : m_type(TYPE_BASIC) + : m_type(VARTYPE_BASIC) { m_data.basic.type = basicType; m_data.basic.precision = precision; } VarType::VarType (const VarType& elementType, int arraySize) - : m_type(TYPE_ARRAY) + : m_type(VARTYPE_ARRAY) { DE_ASSERT(arraySize >= 0 || arraySize == UNSIZED_ARRAY); m_data.array.size = arraySize; @@ -55,14 +55,14 @@ VarType::VarType (const VarType& elementType, int arraySize) } VarType::VarType (const StructType* structPtr) - : m_type(TYPE_STRUCT) + : m_type(VARTYPE_STRUCT) { m_data.structPtr = structPtr; } VarType::~VarType (void) { - if (m_type == TYPE_ARRAY) + if (m_type == VARTYPE_ARRAY) delete m_data.array.elementType; } @@ -71,12 +71,12 @@ VarType& VarType::operator= (const VarType& other) if (this == &other) return *this; // Self-assignment. - VarType *oldElementType = m_type == TYPE_ARRAY ? m_data.array.elementType : DE_NULL; + VarType *oldElementType = m_type == VARTYPE_ARRAY ? m_data.array.elementType : DE_NULL; m_type = other.m_type; m_data = Data(); - if (m_type == TYPE_ARRAY) + if (m_type == VARTYPE_ARRAY) { m_data.array.elementType = new VarType(*other.m_data.array.elementType); m_data.array.size = other.m_data.array.size; @@ -93,10 +93,10 @@ int VarType::getScalarSize (void) const { switch (m_type) { - case TYPE_BASIC: return glu::getDataTypeScalarSize(m_data.basic.type); - case TYPE_ARRAY: return m_data.array.elementType->getScalarSize()*m_data.array.size; + case VARTYPE_BASIC: return glu::getDataTypeScalarSize(m_data.basic.type); + case VARTYPE_ARRAY: return m_data.array.elementType->getScalarSize()*m_data.array.size; - case TYPE_STRUCT: + case VARTYPE_STRUCT: { int size = 0; for (StructType::ConstIterator iter = m_data.structPtr->begin(); iter != m_data.structPtr->end(); iter++) @@ -117,15 +117,15 @@ bool VarType::operator== (const VarType& other) const switch (m_type) { - case TYPE_BASIC: + case VARTYPE_BASIC: return m_data.basic.type == other.m_data.basic.type && m_data.basic.precision == other.m_data.basic.precision; - case TYPE_ARRAY: + case VARTYPE_ARRAY: return *m_data.array.elementType == *other.m_data.array.elementType && m_data.array.size == other.m_data.array.size; - case TYPE_STRUCT: + case VARTYPE_STRUCT: return m_data.structPtr == other.m_data.structPtr; default: diff --git a/framework/opengl/gluVarType.hpp b/framework/opengl/gluVarType.hpp index eb2056b25..4e18496e3 100644 --- a/framework/opengl/gluVarType.hpp +++ b/framework/opengl/gluVarType.hpp @@ -55,9 +55,9 @@ public: explicit VarType (const StructType* structPtr); //!< Struct type constructor. ~VarType (void); - bool isBasicType (void) const { return m_type == TYPE_BASIC; } - bool isArrayType (void) const { return m_type == TYPE_ARRAY; } - bool isStructType (void) const { return m_type == TYPE_STRUCT; } + bool isBasicType (void) const { return m_type == VARTYPE_BASIC; } + bool isArrayType (void) const { return m_type == VARTYPE_ARRAY; } + bool isStructType (void) const { return m_type == VARTYPE_STRUCT; } DataType getBasicType (void) const { DE_ASSERT(isBasicType()); return m_data.basic.type; } Precision getPrecision (void) const { DE_ASSERT(isBasicType()); return m_data.basic.precision; } @@ -82,11 +82,11 @@ public: private: enum Type { - TYPE_BASIC, - TYPE_ARRAY, - TYPE_STRUCT, + VARTYPE_BASIC, + VARTYPE_ARRAY, + VARTYPE_STRUCT, - TYPE_LAST + VARTYPE_LAST }; Type m_type; diff --git a/framework/opengl/gluVarTypeUtil.hpp b/framework/opengl/gluVarTypeUtil.hpp index 559da7da4..e969524d4 100644 --- a/framework/opengl/gluVarTypeUtil.hpp +++ b/framework/opengl/gluVarTypeUtil.hpp @@ -79,11 +79,11 @@ struct VarTypeComponent MATRIX_COLUMN, VECTOR_COMPONENT, - TYPE_LAST + VTCTYPE_LAST }; VarTypeComponent (Type type_, int index_) : type(type_), index(index_) {} - VarTypeComponent (void) : type(TYPE_LAST), index(0) {} + VarTypeComponent (void) : type(VTCTYPE_LAST), index(0) {} bool operator== (const VarTypeComponent& other) const { return type == other.type && index == other.index; } bool operator!= (const VarTypeComponent& other) const { return type != other.type || index != other.index; } diff --git a/modules/glshared/glsFragOpInteractionCase.cpp b/modules/glshared/glsFragOpInteractionCase.cpp index 5b684205e..563e344be 100644 --- a/modules/glshared/glsFragOpInteractionCase.cpp +++ b/modules/glshared/glsFragOpInteractionCase.cpp @@ -313,7 +313,7 @@ static void setupAttributes (sglr::Context& ctx, const VertexDataStorage& vertex for (int attribNdx = 0; attribNdx < vertexData.getNumEntries(); ++attribNdx) { const glu::VertexArrayBinding bindingPtr = getEntryWithPointer(vertexData, attribNdx); - const int attribLoc = bindingPtr.binding.type == glu::BindingPoint::TYPE_NAME ? ctx.getAttribLocation(program, bindingPtr.binding.name.c_str()) : bindingPtr.binding.location; + const int attribLoc = bindingPtr.binding.type == glu::BindingPoint::BPTYPE_NAME ? ctx.getAttribLocation(program, bindingPtr.binding.name.c_str()) : bindingPtr.binding.location; DE_ASSERT(bindingPtr.pointer.componentType == glu::VTX_COMP_FLOAT); |