summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2023-02-02 16:53:08 -0800
committerPokechu22 <Pokechu022@gmail.com>2023-02-09 16:23:49 -0800
commit3024ca2146cfdae2e7fb231e8d180dfc81e1a74e (patch)
tree1422619a72cdcdf51e1d1e60509859f664d2d762
parentac7a17579eea61c627bcf76b5758718e64caeeb4 (diff)
Suppress memcpy writing to an object with no trivial copy-assignment warnings
We need to copy padding in most of these cases, and the objects are trivially copyable; however, BitField prevents trivial copy-assignment.
-rw-r--r--Source/Core/Core/FifoPlayer/FifoPlayer.cpp7
-rw-r--r--Source/Core/Core/HW/MemoryInterface.cpp7
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp7
-rw-r--r--Source/Core/VideoCommon/CPMemory.cpp7
-rw-r--r--Source/Core/VideoCommon/ShaderCache.cpp14
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp7
6 files changed, 49 insertions, 0 deletions
diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
index cacd2cb907..96a8ca9a4c 100644
--- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
+++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
@@ -101,7 +101,14 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
part_start = offset;
// Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after
// primitive data, and the first opcode might update cpmem
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
std::memcpy(&cpmem, &analyzer.m_cpmem, sizeof(CPState));
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
}
if (analyzer.m_end_of_primitives)
{
diff --git a/Source/Core/Core/HW/MemoryInterface.cpp b/Source/Core/Core/HW/MemoryInterface.cpp
index d27c6ed24c..62452bcde9 100644
--- a/Source/Core/Core/HW/MemoryInterface.cpp
+++ b/Source/Core/Core/HW/MemoryInterface.cpp
@@ -150,7 +150,14 @@ void Init()
{
auto& state = Core::System::GetInstance().GetMemoryInterfaceState().GetData();
static_assert(std::is_trivially_copyable_v<MIMemStruct>);
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
std::memset(&state.mi_mem, 0, sizeof(MIMemStruct));
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
}
void Shutdown()
diff --git a/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp b/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp
index d534a81eb5..3d65694167 100644
--- a/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp
@@ -136,7 +136,14 @@ static bool DeserializeExtensionState(DesiredWiimoteState* state,
return false;
auto& e = state->extension.data.emplace<T>();
static_assert(std::is_trivially_copyable_v<T>);
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
std::memcpy(&e, &serialized.data[offset], sizeof(T));
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
return true;
}
diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp
index d2371834a3..3d72a6f70b 100644
--- a/Source/Core/VideoCommon/CPMemory.cpp
+++ b/Source/Core/VideoCommon/CPMemory.cpp
@@ -17,7 +17,14 @@ CPState g_preprocess_cp_state;
void CopyPreprocessCPStateFromMain()
{
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
std::memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState));
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
}
std::pair<std::string, std::string> GetCPRegInfo(u8 cmd, u32 value)
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp
index 98c915a7ee..1c01356c99 100644
--- a/Source/Core/VideoCommon/ShaderCache.cpp
+++ b/Source/Core/VideoCommon/ShaderCache.cpp
@@ -608,7 +608,14 @@ AbstractPipelineConfig ShaderCache::GetGXPipelineConfig(
static GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in)
{
GXPipelineUid out;
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
memcpy(&out, &in, sizeof(out)); // copy padding
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
pixel_shader_uid_data* ps = out.ps_uid.GetUidData();
BlendingState& blend = out.blending_state;
@@ -778,7 +785,14 @@ ShaderCache::GetGXPipelineConfig(const GXPipelineUid& config_in)
static GXUberPipelineUid ApplyDriverBugs(const GXUberPipelineUid& in)
{
GXUberPipelineUid out;
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
memcpy(&out, &in, sizeof(out)); // Copy padding
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
out.vertex_format = nullptr;
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index f3d580b801..49f139c208 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -153,7 +153,14 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl)
// The padding in the structs can cause the memcmp() in the map to create duplicates.
// Avoid this by initializing the padding to zero.
PortableVertexDeclaration new_decl;
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
std::memset(&new_decl, 0, sizeof(new_decl));
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
new_decl.stride = decl.stride;
auto MakeDummyAttribute = [](AttributeFormat& attr, ComponentFormat type, int components,