From b41a9d6f0bbc891d4d9d7bdf3b349fa2a99dab7e Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Wed, 27 Jun 2018 17:15:10 -0400 Subject: [PATCH] Fix pedantic narrowing conversion error. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Clang treats conversion of an unsigned constant to a signed one that doesn't fit its range as an error. Make Visual Studio also produce an error. Change-Id: I2d392d5ba7765b72aa9e9478c5eee02102bdf286 Reviewed-on: https://swiftshader-review.googlesource.com/19648 Tested-by: Nicolas Capens Reviewed-by: Alexis Hétu --- src/OpenGL/compiler/Compiler.vcxproj | 12 ++++++------ src/OpenGL/compiler/preprocessor/preprocessor.vcxproj | 8 ++++---- src/OpenGL/libEGL/libEGL.vcxproj | 12 ++++++------ src/OpenGL/libGL/libGL.vcxproj | 12 ++++++------ src/OpenGL/libGLES_CM/libGLES_CM.vcxproj | 12 ++++++------ src/OpenGL/libGLESv2/libGLESv2.vcxproj | 12 ++++++------ src/Reactor/Reactor.vcxproj | 12 ++++++------ src/Reactor/Subzero.vcxproj | 8 ++++---- src/Reactor/SubzeroLLVMDependencies.vcxproj | 8 ++++---- src/Reactor/SubzeroTest.vcxproj | 8 ++++---- src/SwiftShader/SwiftShader.vcxproj | 12 ++++++------ tests/unittests/unittests.cpp | 4 ++-- tests/unittests/unittests.vcxproj | 8 ++++---- 13 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/OpenGL/compiler/Compiler.vcxproj b/src/OpenGL/compiler/Compiler.vcxproj index 1360d93dd..9036043a6 100644 --- a/src/OpenGL/compiler/Compiler.vcxproj +++ b/src/OpenGL/compiler/Compiler.vcxproj @@ -127,7 +127,7 @@ true 5030;4005; true - 4018;5038 + 4018;5038;4838 Queue @@ -146,7 +146,7 @@ true 5030;4005;4267;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 Queue @@ -164,7 +164,7 @@ true 5030;4005; true - 4018;5038 + 4018;5038;4838 Queue @@ -182,7 +182,7 @@ true 5030;4005;4267;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 Queue @@ -200,7 +200,7 @@ false true 5030;4005; - 4018;5038 + 4018;5038;4838 Queue @@ -218,7 +218,7 @@ false true 5030;4005;4267;%(DisableSpecificWarnings) - 4018;5038 + 4018;5038;4838 Queue diff --git a/src/OpenGL/compiler/preprocessor/preprocessor.vcxproj b/src/OpenGL/compiler/preprocessor/preprocessor.vcxproj index 00609040c..0a7f488df 100644 --- a/src/OpenGL/compiler/preprocessor/preprocessor.vcxproj +++ b/src/OpenGL/compiler/preprocessor/preprocessor.vcxproj @@ -90,7 +90,7 @@ true 4005; true - 4018;5038 + 4018;5038;4838 true @@ -104,7 +104,7 @@ true 4005;4267;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 true @@ -120,7 +120,7 @@ true 4005; true - 4018;5038 + 4018;5038;4838 true @@ -138,7 +138,7 @@ true 4005;4267;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 true diff --git a/src/OpenGL/libEGL/libEGL.vcxproj b/src/OpenGL/libEGL/libEGL.vcxproj index 172d6b866..7e3c6fc11 100644 --- a/src/OpenGL/libEGL/libEGL.vcxproj +++ b/src/OpenGL/libEGL/libEGL.vcxproj @@ -132,7 +132,7 @@ true true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -164,7 +164,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans true true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -197,7 +197,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans true true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -230,7 +230,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans true true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -265,7 +265,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans false true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -298,7 +298,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\trans false true 5030 - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) diff --git a/src/OpenGL/libGL/libGL.vcxproj b/src/OpenGL/libGL/libGL.vcxproj index ea8f5b519..676f0b59a 100644 --- a/src/OpenGL/libGL/libGL.vcxproj +++ b/src/OpenGL/libGL/libGL.vcxproj @@ -154,7 +154,7 @@ ProgramDatabase true true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -181,7 +181,7 @@ copy "$(OutDir)opengl32.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\"ProgramDatabase true true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -215,7 +215,7 @@ copy "$(OutDir)opengl32.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\"true false true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -250,7 +250,7 @@ copy "$(OutDir)opengl32.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\"true false true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -285,7 +285,7 @@ copy "$(OutDir)opengl32.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\"true true false - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -318,7 +318,7 @@ copy "$(OutDir)opengl32.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\"true true false - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj index 253e02454..d146d12b0 100644 --- a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj +++ b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj @@ -136,7 +136,7 @@ ProgramDatabase true true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -165,7 +165,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\t ProgramDatabase true true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -201,7 +201,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\t true false true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -238,7 +238,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\t true false true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -275,7 +275,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\t true true false - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -310,7 +310,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\t true true false - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj b/src/OpenGL/libGLESv2/libGLESv2.vcxproj index e932abc44..80766fd8e 100644 --- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj +++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj @@ -138,7 +138,7 @@ true 5030;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -169,7 +169,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr true 5030;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -207,7 +207,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr true 5030;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -246,7 +246,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr true 5030;%(DisableSpecificWarnings) true - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -285,7 +285,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr false true 5030;%(DisableSpecificWarnings) - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) @@ -322,7 +322,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr false true 5030;%(DisableSpecificWarnings) - 4018;5038 + 4018;5038;4838 dxguid.lib;WS2_32.lib;%(AdditionalDependencies) diff --git a/src/Reactor/Reactor.vcxproj b/src/Reactor/Reactor.vcxproj index 6bd181392..788de64b9 100644 --- a/src/Reactor/Reactor.vcxproj +++ b/src/Reactor/Reactor.vcxproj @@ -123,7 +123,7 @@ true false true - 4018;5038 + 4018;5038;4838 false @@ -149,7 +149,7 @@ false true true - 4018;5038 + 4018;5038;4838 false @@ -179,7 +179,7 @@ false true true - 4018;5038 + 4018;5038;4838 false @@ -207,7 +207,7 @@ true false true - 4018;5038 + 4018;5038;4838 false @@ -239,7 +239,7 @@ false true true - 4018;5038 + 4018;5038;4838 false @@ -270,7 +270,7 @@ true false true - 4018;5038 + 4018;5038;4838 false diff --git a/src/Reactor/Subzero.vcxproj b/src/Reactor/Subzero.vcxproj index 1662e0ff5..688e83992 100644 --- a/src/Reactor/Subzero.vcxproj +++ b/src/Reactor/Subzero.vcxproj @@ -91,7 +91,7 @@ MultiThreadedDebug src/IceTypes.h true - 5038 + 5038;4838 Console @@ -110,7 +110,7 @@ MultiThreadedDebug src/IceTypes.h true - 5038 + 5038;4838 Console @@ -131,7 +131,7 @@ src/IceTypes.h MultiThreaded true - 5038 + 5038;4838 Console @@ -158,7 +158,7 @@ src/IceTypes.h MultiThreaded true - 5038 + 5038;4838 Console diff --git a/src/Reactor/SubzeroLLVMDependencies.vcxproj b/src/Reactor/SubzeroLLVMDependencies.vcxproj index 87502e921..08167be22 100644 --- a/src/Reactor/SubzeroLLVMDependencies.vcxproj +++ b/src/Reactor/SubzeroLLVMDependencies.vcxproj @@ -78,7 +78,7 @@ $(SolutionDir)third_party\llvm-subzero\include;$(SolutionDir)third_party\llvm-subzero\build\Windows\include MultiThreadedDebug true - 4018;5038 + 4018;5038;4838 @@ -90,7 +90,7 @@ $(SolutionDir)third_party\llvm-subzero\include;$(SolutionDir)third_party\llvm-subzero\build\Windows\include MultiThreadedDebug true - 4018;5038 + 4018;5038;4838 @@ -104,7 +104,7 @@ $(SolutionDir)third_party\llvm-subzero\include;$(SolutionDir)third_party\llvm-subzero\build\Windows\include MultiThreaded true - 4018;5038 + 4018;5038;4838 true @@ -122,7 +122,7 @@ $(SolutionDir)third_party\llvm-subzero\include;$(SolutionDir)third_party\llvm-subzero\build\Windows\include MultiThreaded true - 4018;5038 + 4018;5038;4838 true diff --git a/src/Reactor/SubzeroTest.vcxproj b/src/Reactor/SubzeroTest.vcxproj index febe35274..3379dc463 100644 --- a/src/Reactor/SubzeroTest.vcxproj +++ b/src/Reactor/SubzeroTest.vcxproj @@ -95,7 +95,7 @@ MultiThreadedDebug $(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\subzero\src\;$(SolutionDir)third_party\subzero\unittest\;$(SolutionDir)third_party\llvm-subzero\include\;$(SolutionDir)third_party\llvm-subzero\build\Windows\include;SubmoduleCheck;%(AdditionalIncludeDirectories) gtest/gtest.h - 5038 + 5038;4838 Console @@ -112,7 +112,7 @@ MultiThreadedDebug $(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\subzero\src\;$(SolutionDir)third_party\subzero\unittest\;$(SolutionDir)third_party\llvm-subzero\include\;$(SolutionDir)third_party\llvm-subzero\build\Windows\include;SubmoduleCheck;%(AdditionalIncludeDirectories) gtest/gtest.h - 5038 + 5038;4838 Console @@ -131,7 +131,7 @@ MultiThreaded $(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\subzero\src\;$(SolutionDir)third_party\subzero\unittest\;$(SolutionDir)third_party\llvm-subzero\include\;$(SolutionDir)third_party\llvm-subzero\build\Windows\include;SubmoduleCheck;%(AdditionalIncludeDirectories) gtest/gtest.h - 5038 + 5038;4838 Console @@ -152,7 +152,7 @@ MultiThreaded $(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\subzero\src\;$(SolutionDir)third_party\subzero\unittest\;$(SolutionDir)third_party\llvm-subzero\include\;$(SolutionDir)third_party\llvm-subzero\build\Windows\include;SubmoduleCheck;%(AdditionalIncludeDirectories) gtest/gtest.h - 5038 + 5038;4838 Console diff --git a/src/SwiftShader/SwiftShader.vcxproj b/src/SwiftShader/SwiftShader.vcxproj index ee9521e91..7097609c7 100644 --- a/src/SwiftShader/SwiftShader.vcxproj +++ b/src/SwiftShader/SwiftShader.vcxproj @@ -135,7 +135,7 @@ false true true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -171,7 +171,7 @@ false true true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -207,7 +207,7 @@ false true true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -241,7 +241,7 @@ false false true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -280,7 +280,7 @@ false true true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) @@ -317,7 +317,7 @@ false false true - 4018;5038 + 4018;5038;4838 %(AdditionalDependencies) diff --git a/tests/unittests/unittests.cpp b/tests/unittests/unittests.cpp index 371fce3c1..80bc8872d 100644 --- a/tests/unittests/unittests.cpp +++ b/tests/unittests/unittests.cpp @@ -609,14 +609,14 @@ TEST_F(SwiftShaderTest, ReadHalfFloat) glClear(GL_COLOR_BUFFER_BIT); EXPECT_GLENUM_EQ(GL_NONE, glGetError()); - int16_t pixel[3] = { 0x1234, 0x3F80, 0xAAAA }; + uint16_t pixel[3] = { 0x1234, 0x3F80, 0xAAAA }; GLint x = 6; GLint y = 3; glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 1, 1, GL_RGB, GL_HALF_FLOAT, pixel); // This relies on GL_HALF_FLOAT being a valid type for read-back, // which isn't guaranteed by the spec but is supported by SwiftShader. - int16_t read_color[3] = { 0, 0, 0 }; + uint16_t read_color[3] = { 0, 0, 0 }; glReadPixels(x, y, 1, 1, GL_RGB, GL_HALF_FLOAT, &read_color); EXPECT_GLENUM_EQ(GL_NONE, glGetError()); EXPECT_EQ(read_color[0], pixel[0]); diff --git a/tests/unittests/unittests.vcxproj b/tests/unittests/unittests.vcxproj index b92398ff9..033f5b83d 100644 --- a/tests/unittests/unittests.vcxproj +++ b/tests/unittests/unittests.vcxproj @@ -96,7 +96,7 @@ $(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories) - 4018;5038 + 4018;5038;4838 Console @@ -114,7 +114,7 @@ $(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories) - 4018;5038 + 4018;5038;4838 Console @@ -134,7 +134,7 @@ $(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories) - 4018;5038 + 4018;5038;4838 Console @@ -156,7 +156,7 @@ $(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories) - 4018;5038 + 4018;5038;4838 Console -- 2.11.0