Enable the -Wdeprecated-copy compiler warning
Remaining occurences of this warning have been fixed. Note the warning
is also added by -Wextra so we previously explicitly disabled it with
-Wno-deprecated-copy. While removing the latter should suffice to re-
enable it, it's useful to make it explicit since support for implicit
copy constructors when a user-defined assignment operator has been
defined may be removed in the near future.
Bug: b/191417833
Change-Id: If6721ae900afd530750a7d05ccc40365924d4c25
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55028
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e49f78..d3c478d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -424,6 +424,7 @@
"-Wreorder"
"-Wsign-compare"
"-Wmissing-braces"
+ "-Wdeprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator.
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@@ -449,7 +450,7 @@
endif()
endif()
- # Disable pedanitc warnings
+ # Disable pedantic warnings
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND SWIFTSHADER_COMPILE_OPTIONS
"-Wno-ignored-attributes" # ignoring attributes on template argument 'X'
@@ -470,7 +471,6 @@
"-Wno-undefined-var-template" # instantiation of variable 'X' required here, but no definition is available
"-Wno-extra-semi" # extra ';' after member function definition
"-Wno-unused-parameter" # unused parameter 'X'
- "-Wno-deprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator.
# Silence errors caused by unknown warnings when building with older
# versions of Clang. This demands checking that warnings added above
diff --git a/src/Device/BC_Decoder.cpp b/src/Device/BC_Decoder.cpp
index d91235f..b4b4dd6 100644
--- a/src/Device/BC_Decoder.cpp
+++ b/src/Device/BC_Decoder.cpp
@@ -325,12 +325,9 @@
RGBA &operator=(const RGBA &other)
{
- if(this != &other)
- {
- this->r = other.r;
- this->g = other.g;
- this->b = other.b;
- }
+ this->r = other.r;
+ this->g = other.g;
+ this->b = other.b;
return *this;
}
@@ -350,12 +347,15 @@
{
}
+ Color(const Color &other)
+ {
+ this->rgba = other.rgba;
+ }
+
Color &operator=(const Color &other)
{
- if(this != &other)
- {
- this->rgba = other.rgba;
- }
+ this->rgba = other.rgba;
+
return *this;
}
diff --git a/src/Renderer/Matrix.hpp b/src/Renderer/Matrix.hpp
index 41281a6..b9fce24 100644
--- a/src/Renderer/Matrix.hpp
+++ b/src/Renderer/Matrix.hpp
@@ -36,7 +36,7 @@
float m41, float m42, float m43, float m44);
Matrix(const Vector &v1, const Vector &v2, const Vector &v3); // Column vectors
- Matrix &operator=(const Matrix &N);
+ Matrix &operator=(const Matrix &N) = default;
// Row major order
float m[4][4];
@@ -181,18 +181,6 @@
M(4, 1) = 0; M(4, 2) = 0; M(4, 3) = 0; M(4, 4) = 1;
}
- inline Matrix &Matrix::operator=(const Matrix &N)
- {
- Matrix &M = *this;
-
- M(1, 1) = N(1, 1); M(1, 2) = N(1, 2); M(1, 3) = N(1, 3); M(1, 4) = N(1, 4);
- M(2, 1) = N(2, 1); M(2, 2) = N(2, 2); M(2, 3) = N(2, 3); M(2, 4) = N(2, 4);
- M(3, 1) = N(3, 1); M(3, 2) = N(3, 2); M(3, 3) = N(3, 3); M(3, 4) = N(3, 4);
- M(4, 1) = N(4, 1); M(4, 2) = N(4, 2); M(4, 3) = N(4, 3); M(4, 4) = N(4, 4);
-
- return M;
- }
-
inline float *Matrix::operator[](int i)
{
return m[i];
diff --git a/src/System/Half.cpp b/src/System/Half.cpp
index fd04a31..abadc2d 100644
--- a/src/System/Half.cpp
+++ b/src/System/Half.cpp
@@ -85,13 +85,6 @@
return (float &)fp32i;
}
-half &half::operator=(half h)
-{
- fp16i = h.fp16i;
-
- return *this;
-}
-
half &half::operator=(float f)
{
*this = half(f);
diff --git a/src/System/Half.hpp b/src/System/Half.hpp
index 84025ef..4576e4f 100644
--- a/src/System/Half.hpp
+++ b/src/System/Half.hpp
@@ -30,7 +30,6 @@
operator float() const;
- half &operator=(half h);
half &operator=(float f);
private:
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
index 5d1fbb7..c26b6be 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
@@ -426,13 +426,7 @@
class Block {
public:
Block() = delete;
- Block &operator=(const Block &Rhs) {
- GlobalAbbrevs = Rhs.GlobalAbbrevs;
- NumGlobalAbbrevs = Rhs.NumGlobalAbbrevs;
- LocalAbbrevs = Rhs.LocalAbbrevs;
- CodeAbbrev = Rhs.CodeAbbrev;
- return *this;
- }
+ Block &operator=(const Block &Rhs) = default;
Block(NaClBitstreamReader::BlockInfo *GlobalAbbrevs,
NaClBitcodeSelectorAbbrev &CodeAbbrev)
: GlobalAbbrevs(GlobalAbbrevs),