summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-05-06 13:41:54 +0000
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-05-06 13:41:54 +0000
commit059c038861ef09aaee7dac69d8bcc75699f0f886 (patch)
treeb693a377d31fb6715e962b46e924f057329bbd6a
parent8d416103aa9acee70cc97646c681de6f8863514a (diff)
downloadllvm-059c038861ef09aaee7dac69d8bcc75699f0f886.tar.gz
Fix compilation warnings when compiling with GCC 7.3
Differential Revision: https://reviews.llvm.org/D61046 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360044 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/AMDGPU/R600ISelLowering.cpp6
-rw-r--r--unittests/IR/ConstantRangeTest.cpp1
-rw-r--r--unittests/Support/TypeTraitsTest.cpp21
-rw-r--r--unittests/Transforms/Scalar/CMakeLists.txt5
-rw-r--r--unittests/Transforms/Scalar/LoopPassManagerTest.cpp10
5 files changed, 33 insertions, 10 deletions
diff --git a/lib/Target/AMDGPU/R600ISelLowering.cpp b/lib/Target/AMDGPU/R600ISelLowering.cpp
index 9f7635dd8676..4aa2778c6147 100644
--- a/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ b/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@ static SDValue CompactSwizzlableVector(
if (NewBldVec[i].isUndef())
continue;
+ // Fix spurious warning with gcc 7.3 -O3
+ // warning: array subscript is above array bounds [-Warray-bounds]
+ // if (NewBldVec[i] == NewBldVec[j]) {
+ // ~~~~~~~~~~~^
+ if (i >= 4)
+ continue;
for (unsigned j = 0; j < i; j++) {
if (NewBldVec[i] == NewBldVec[j]) {
NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
diff --git a/unittests/IR/ConstantRangeTest.cpp b/unittests/IR/ConstantRangeTest.cpp
index a1c66f33abbb..b6a794f09187 100644
--- a/unittests/IR/ConstantRangeTest.cpp
+++ b/unittests/IR/ConstantRangeTest.cpp
@@ -459,6 +459,7 @@ void testBinarySetOperationExhaustive(Fn1 OpFn, Fn2 InResultFn) {
}
}
+ (void)HaveInterrupt3;
assert(!HaveInterrupt3 && "Should have at most three ranges");
ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
diff --git a/unittests/Support/TypeTraitsTest.cpp b/unittests/Support/TypeTraitsTest.cpp
index d33dee97ecab..e7a102543e66 100644
--- a/unittests/Support/TypeTraitsTest.cpp
+++ b/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
namespace {
@@ -71,6 +72,26 @@ template void TrivialityTester<Z &&, false, true>();
template void TrivialityTester<A &&, false, true>();
template void TrivialityTester<B &&, false, true>();
+TEST(Triviality, Tester) {
+ TrivialityTester<int, true, true>();
+ TrivialityTester<void *, true, true>();
+ TrivialityTester<int &, true, true>();
+ TrivialityTester<int &&, false, true>();
+
+ TrivialityTester<X, true, true>();
+ TrivialityTester<Y, false, false>();
+ TrivialityTester<Z, false, false>();
+ TrivialityTester<A, true, false>();
+ TrivialityTester<B, false, true>();
+
+ TrivialityTester<Z &, true, true>();
+ TrivialityTester<A &, true, true>();
+ TrivialityTester<B &, true, true>();
+ TrivialityTester<Z &&, false, true>();
+ TrivialityTester<A &&, false, true>();
+ TrivialityTester<B &&, false, true>();
+}
+
} // namespace triviality
} // end anonymous namespace
diff --git a/unittests/Transforms/Scalar/CMakeLists.txt b/unittests/Transforms/Scalar/CMakeLists.txt
index 2762799d6124..3d01d5c53341 100644
--- a/unittests/Transforms/Scalar/CMakeLists.txt
+++ b/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@ set(LLVM_LINK_COMPONENTS
add_llvm_unittest(ScalarTests
LoopPassManagerTest.cpp
)
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+ set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
diff --git a/unittests/Transforms/Scalar/LoopPassManagerTest.cpp b/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
index fc94b6e8c1ab..0743cba852da 100644
--- a/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ b/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
#include "llvm/IR/PassManager.h"
#include "llvm/Support/SourceMgr.h"
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#if defined(__GNUC__) && __GNUC__ > 5
-# pragma GCC diagnostic pop
-#endif
-
using namespace llvm;
namespace {