From 8ddb65c57dab2268bd7ad39804e9392ec25cd72f Mon Sep 17 00:00:00 2001
From: Clark Coleman <clc@zephyr-software.com>
Date: Fri, 4 Jun 2021 00:01:04 -0400
Subject: [PATCH] Make pragmas depend on GCC versions to avoid compilation
 errors.

---
 include/interfaces/idapro/STARSFunction.h     | 4 ++++
 include/interfaces/idapro/all.h               | 8 +++++++-
 src/interfaces/idapro/STARSIDAInstruction.cpp | 8 +++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/interfaces/idapro/STARSFunction.h b/include/interfaces/idapro/STARSFunction.h
index fd5824c0..f7c64884 100644
--- a/include/interfaces/idapro/STARSFunction.h
+++ b/include/interfaces/idapro/STARSFunction.h
@@ -1,13 +1,17 @@
 #ifndef STARS_IDA_Function_h
 #define STARS_IDA_Function_h
 
+#if __GCC__ >= 8
 #pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
 
 #include <pro.h>
 #include <funcs.hpp>
 #include <frame.hpp>
 
+#if __GCC__ >= 8
 #pragma GCC diagnostic pop
+#endif
 
 #include "interfaces/STARSTypes.h"
 
diff --git a/include/interfaces/idapro/all.h b/include/interfaces/idapro/all.h
index f8b3134a..5a2b9738 100644
--- a/include/interfaces/idapro/all.h
+++ b/include/interfaces/idapro/all.h
@@ -7,9 +7,12 @@
 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
 #pragma GCC diagnostic ignored "-Wparentheses"
 #pragma GCC diagnostic ignored "-Wsign-compare"
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 
+#if __GCC__ >= 8
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
+
 #include <fpro.h>
 #include <pro.h>
 #include <ida.hpp>
@@ -25,7 +28,10 @@
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic pop
+
+#if __GCC__ >= 8
 #pragma GCC diagnostic pop
+#endif
 
 #include <assert.h>
 
diff --git a/src/interfaces/idapro/STARSIDAInstruction.cpp b/src/interfaces/idapro/STARSIDAInstruction.cpp
index ed9053e6..19661443 100644
--- a/src/interfaces/idapro/STARSIDAInstruction.cpp
+++ b/src/interfaces/idapro/STARSIDAInstruction.cpp
@@ -60,10 +60,16 @@ void STARS_IDA_Instruction_t::InitOperand(op_t &InitOp) const {
 	InitOp.specflag2 = 0;
 	InitOp.specflag3 = 0;
 	InitOp.specflag4 = 0;
-#else
+#else // not 0
+
+#if __GCC__ >= 8
 #pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
 	(void) memset(&InitOp, 0, sizeof(op_t));
+
+#if __GCC__ >= 8
 #pragma GCC diagnostic pop
+#endif
 	
 #if (IDA_SDK_VERSION < 700)
 	InitOp.dtyp = global_STARS_program->GetSTARS_ISA_dtyp();
-- 
GitLab