GCC 11 build fixes
authorMika Väinölä <mika.vainola@siru.fi>
Wed, 10 Mar 2021 11:16:38 +0000 (13:16 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 5 May 2021 05:52:10 +0000 (05:52 +0000)
Some files used std::numeric_limits without including <limits> and
failed to compile.

Some dynamic casts and calls to AndroidHardwareBufferExternalApi::
getInstance() produced nonnull warnings. Suppress these by
wrapping them in if statements.

Update Amber to suppress some new uninitialized variable warnings.

This commit also removes implicit-fallthrough from the list of ignored
GCC warnings in check_build_sanity.py. All such warnings in the CTS
should be fixed by now and recent versions of Clang also support
this warning.

Affects: All Amber tests

VK-GL-CTS issue: 2842

Change-Id: I5bd290f9c312a30c2fcb223307c7b5c785a0fa92

18 files changed:
external/fetch_sources.py
external/vulkancts/framework/vulkan/vkRayTracingUtil.cpp
external/vulkancts/framework/vulkan/vkRayTracingUtil.hpp
external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp
external/vulkancts/modules/vulkan/draw/vktDrawDepthClampTests.cpp
external/vulkancts/modules/vulkan/memory/vktMemoryDeviceMemoryReportTests.cpp
external/vulkancts/modules/vulkan/ray_query/vktRayQueryAccelerationStructuresTests.cpp
external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingAccelerationStructuresTests.cpp
external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuildTests.cpp
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmNonSemanticInfoTests.cpp
external/vulkancts/modules/vulkan/synchronization/vktSynchronizationUtil.cpp
external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp
external/vulkancts/modules/vulkan/ycbcr/vktYCbCrUtil.cpp
framework/opengl/simplereference/sglrReferenceContext.cpp
modules/egl/teglImageFormatTests.cpp
modules/glshared/glsBuiltinPrecisionTests.cpp
scripts/check_build_sanity.py

index bcebd1d..5f9afc4 100644 (file)
@@ -333,7 +333,7 @@ PACKAGES = [
        GitRepo(
                "https://github.com/google/amber.git",
                None,
-               "dabae26164714abf951c6815a2b4513260f7c6a4",
+               "aa69a0ac23ea7f68dd32bbef210546a5d84c1734",
                "amber"),
 ]
 
index 9bdb8be..233e0cc 100644 (file)
@@ -118,7 +118,11 @@ NativeHandle::NativeHandle (const NativeHandle& other)
                DE_ASSERT(other.m_fd == -1);
                DE_ASSERT(!other.m_win32Handle.internal);
                m_androidHardwareBuffer = other.m_androidHardwareBuffer;
-               AndroidHardwareBufferExternalApi::getInstance()->acquire(m_androidHardwareBuffer);
+
+               if (AndroidHardwareBufferExternalApi* ahbApi = AndroidHardwareBufferExternalApi::getInstance())
+                       ahbApi->acquire(m_androidHardwareBuffer);
+               else
+                       DE_FATAL("Platform doesn't support Android Hardware Buffer handles");
        }
        else
                DE_FATAL("Native handle can't be duplicated");
@@ -194,7 +198,11 @@ void NativeHandle::reset (void)
        {
                DE_ASSERT(m_fd == -1);
                DE_ASSERT(!m_win32Handle.internal);
-               AndroidHardwareBufferExternalApi::getInstance()->release(m_androidHardwareBuffer);
+
+               if (AndroidHardwareBufferExternalApi* ahbApi = AndroidHardwareBufferExternalApi::getInstance())
+                       ahbApi->release(m_androidHardwareBuffer);
+               else
+                       DE_FATAL("Platform doesn't support Android Hardware Buffer handles");
        }
        m_fd                                    = -1;
        m_win32Handle                   = vk::pt::Win32Handle(DE_NULL);
index 0f5f4c1..e97ea7a 100644 (file)
@@ -39,6 +39,8 @@
 #include "tcuPlatform.hpp"
 #include "tcuCommandLine.hpp"
 
+#include <limits>
+
 #if ( DE_OS == DE_OS_WIN32 )
        #define NOMINMAX
        #define WIN32_LEAN_AND_MEAN
index f89ed72..e68917a 100644 (file)
@@ -38,6 +38,8 @@
 #include "deSTLUtil.hpp"
 #include "deUniquePtr.hpp"
 
+#include <limits>
+
 namespace vkt
 {
 namespace ycbcr
index d17a275..bd38151 100644 (file)
@@ -2357,9 +2357,19 @@ tcu::PixelBufferAccess ReferenceContext::getFboAttachment (const rc::Framebuffer
                        TCU_CHECK(texture);
 
                        if (texture->getType() == Texture::TYPE_2D)
-                               return dynamic_cast<Texture2D*>(texture)->getLevel(attachment.level);
+                       {
+                               if (Texture2D* texture2D = dynamic_cast<Texture2D*>(texture))
+                                       return texture2D->getLevel(attachment.level);
+                               else
+                                       return nullAccess();
+                       }
                        else if (texture->getType() == Texture::TYPE_CUBE_MAP)
-                               return dynamic_cast<TextureCube*>(texture)->getFace(attachment.level, texTargetToFace(attachment.texTarget));
+                       {
+                               if (TextureCube* cubeMap = dynamic_cast<TextureCube*>(texture))
+                                       return cubeMap->getFace(attachment.level, texTargetToFace(attachment.texTarget));
+                               else
+                                       return nullAccess();
+                       }
                        else if (texture->getType() == Texture::TYPE_2D_ARRAY   ||
                                         texture->getType() == Texture::TYPE_3D                 ||
                                         texture->getType() == Texture::TYPE_CUBE_MAP_ARRAY)
@@ -2367,11 +2377,20 @@ tcu::PixelBufferAccess ReferenceContext::getFboAttachment (const rc::Framebuffer
                                tcu::PixelBufferAccess level;
 
                                if (texture->getType() == Texture::TYPE_2D_ARRAY)
-                                       level = dynamic_cast<Texture2DArray*>(texture)->getLevel(attachment.level);
+                               {
+                                       if (Texture2DArray* texture2DArray = dynamic_cast<Texture2DArray*>(texture))
+                                               level = texture2DArray->getLevel(attachment.level);
+                               }
                                else if (texture->getType() == Texture::TYPE_3D)
-                                       level = dynamic_cast<Texture3D*>(texture)->getLevel(attachment.level);
+                               {
+                                       if (Texture3D* texture3D = dynamic_cast<Texture3D*>(texture))
+                                               level = texture3D->getLevel(attachment.level);
+                               }
                                else if (texture->getType() == Texture::TYPE_CUBE_MAP_ARRAY)
-                                       level = dynamic_cast<TextureCubeArray*>(texture)->getLevel(attachment.level);
+                               {
+                                       if (TextureCubeArray* cubeArray = dynamic_cast<TextureCubeArray*>(texture))
+                                               level = cubeArray->getLevel(attachment.level);
+                               }
 
                                void* layerData = static_cast<deUint8*>(level.getDataPtr()) + level.getSlicePitch() * attachment.layer;
 
index 3af7774..aae3132 100644 (file)
@@ -1712,7 +1712,13 @@ void MultiContextRenderTests::init (void)
 
                spec.name = std::string("gles2_") + createAction.label + "_" + renderAction.label;
 
-               const GLenum createFormat = dynamic_cast<const GLES2ImageApi::Create*>(createAction.action.get())->getEffectiveFormat();
+               const GLES2ImageApi::Create* gles2Create = dynamic_cast<const GLES2ImageApi::Create*>(createAction.action.get());
+
+               if (!gles2Create)
+                       DE_FATAL("Dynamic casting to GLES2ImageApi::Create* failed");
+
+               const GLenum createFormat = gles2Create->getEffectiveFormat();
+
                if (isDepthFormat(createFormat) && isStencilFormat(createFormat))
                {
                        // Combined depth and stencil format. Add the clear action label to avoid test
index a1a9962..a774464 100644 (file)
@@ -56,6 +56,7 @@
 #include <iostream>
 #include <map>
 #include <utility>
+#include <limits>
 
 // Uncomment this to get evaluation trace dumps to std::cerr
 // #define GLS_ENABLE_TRACE
index e49d743..3757a2e 100644 (file)
@@ -139,7 +139,7 @@ def runSteps (steps):
                        print("Skip: %s" % step.getName())
 
 COMMON_CFLAGS          = ["-Werror", "-Wno-error=unused-function"]
-COMMON_GCC_CFLAGS      = COMMON_CFLAGS + ["-Wno-implicit-fallthrough", "-Wno-error=array-bounds"]
+COMMON_GCC_CFLAGS      = COMMON_CFLAGS + ["-Wno-error=array-bounds"]
 COMMON_CLANG_CFLAGS    = COMMON_CFLAGS + ["-Wno-error=unused-command-line-argument"]
 GCC_32BIT_CFLAGS       = COMMON_GCC_CFLAGS + ["-m32"]
 CLANG_32BIT_CFLAGS     = COMMON_CLANG_CFLAGS + ["-m32"]