Skip to content

Commit 3024ca2

Browse files
committed
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.
1 parent ac7a175 commit 3024ca2

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

Source/Core/Core/FifoPlayer/FifoPlayer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
101101
part_start = offset;
102102
// Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after
103103
// primitive data, and the first opcode might update cpmem
104+
#ifdef __GNUC__
105+
#pragma GCC diagnostic push
106+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
107+
#endif
104108
std::memcpy(&cpmem, &analyzer.m_cpmem, sizeof(CPState));
109+
#ifdef __GNUC__
110+
#pragma GCC diagnostic pop
111+
#endif
105112
}
106113
if (analyzer.m_end_of_primitives)
107114
{

Source/Core/Core/HW/MemoryInterface.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,14 @@ void Init()
150150
{
151151
auto& state = Core::System::GetInstance().GetMemoryInterfaceState().GetData();
152152
static_assert(std::is_trivially_copyable_v<MIMemStruct>);
153+
#ifdef __GNUC__
154+
#pragma GCC diagnostic push
155+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
156+
#endif
153157
std::memset(&state.mi_mem, 0, sizeof(MIMemStruct));
158+
#ifdef __GNUC__
159+
#pragma GCC diagnostic pop
160+
#endif
154161
}
155162

156163
void Shutdown()

Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ static bool DeserializeExtensionState(DesiredWiimoteState* state,
136136
return false;
137137
auto& e = state->extension.data.emplace<T>();
138138
static_assert(std::is_trivially_copyable_v<T>);
139+
#ifdef __GNUC__
140+
#pragma GCC diagnostic push
141+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
142+
#endif
139143
std::memcpy(&e, &serialized.data[offset], sizeof(T));
144+
#ifdef __GNUC__
145+
#pragma GCC diagnostic pop
146+
#endif
140147
return true;
141148
}
142149

Source/Core/VideoCommon/CPMemory.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ CPState g_preprocess_cp_state;
1717

1818
void CopyPreprocessCPStateFromMain()
1919
{
20+
#ifdef __GNUC__
21+
#pragma GCC diagnostic push
22+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
23+
#endif
2024
std::memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState));
25+
#ifdef __GNUC__
26+
#pragma GCC diagnostic pop
27+
#endif
2128
}
2229

2330
std::pair<std::string, std::string> GetCPRegInfo(u8 cmd, u32 value)

Source/Core/VideoCommon/ShaderCache.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,14 @@ AbstractPipelineConfig ShaderCache::GetGXPipelineConfig(
608608
static GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in)
609609
{
610610
GXPipelineUid out;
611+
#ifdef __GNUC__
612+
#pragma GCC diagnostic push
613+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
614+
#endif
611615
memcpy(&out, &in, sizeof(out)); // copy padding
616+
#ifdef __GNUC__
617+
#pragma GCC diagnostic pop
618+
#endif
612619
pixel_shader_uid_data* ps = out.ps_uid.GetUidData();
613620
BlendingState& blend = out.blending_state;
614621

@@ -778,7 +785,14 @@ ShaderCache::GetGXPipelineConfig(const GXPipelineUid& config_in)
778785
static GXUberPipelineUid ApplyDriverBugs(const GXUberPipelineUid& in)
779786
{
780787
GXUberPipelineUid out;
788+
#ifdef __GNUC__
789+
#pragma GCC diagnostic push
790+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
791+
#endif
781792
memcpy(&out, &in, sizeof(out)); // Copy padding
793+
#ifdef __GNUC__
794+
#pragma GCC diagnostic pop
795+
#endif
782796
if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
783797
out.vertex_format = nullptr;
784798

Source/Core/VideoCommon/VertexLoaderManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,14 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl)
153153
// The padding in the structs can cause the memcmp() in the map to create duplicates.
154154
// Avoid this by initializing the padding to zero.
155155
PortableVertexDeclaration new_decl;
156+
#ifdef __GNUC__
157+
#pragma GCC diagnostic push
158+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
159+
#endif
156160
std::memset(&new_decl, 0, sizeof(new_decl));
161+
#ifdef __GNUC__
162+
#pragma GCC diagnostic pop
163+
#endif
157164
new_decl.stride = decl.stride;
158165

159166
auto MakeDummyAttribute = [](AttributeFormat& attr, ComponentFormat type, int components,

0 commit comments

Comments
 (0)