]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Ignore some stringop-overflow and restrict warnings on sparc users/ahajkova/try-frob
authorMark Wielaard <mark@klomp.org>
Sun, 15 Jan 2023 00:51:53 +0000 (01:51 +0100)
committerAlexandra Hájková <ahajkova@redhat.com>
Mon, 23 Jan 2023 15:39:26 +0000 (16:39 +0100)
For some reason g++ 11.2.1 on s390x produces a spurious warning for
stringop-overread and restruct in fsb-tdep.c for some memcpy calls.
Add new DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
DIAGNOSTIC_IGNORE_RESTRICT macro to suppress these warning.

include/ChangeLog:

* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW): New
macro.
(DIAGNOSTIC_IGNORE_RESTRICT): Likewise.

gdb/ChangeLog:

* fsb-tdep.c (fbsd_make_note_desc): Use
DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW and
DIAGNOSTIC_IGNORE_RESTRICT on sparc.

gdb/fbsd-tdep.c
include/diagnostics.h

index 203390d98805fde2b2311cb44112787291aa91a2..ee2a4b54e8545b86385ff29a77f7c76d56d9fc20 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "auxv.h"
+#include "diagnostics.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -663,7 +664,16 @@ fbsd_make_note_desc (enum target_object object, uint32_t structsize)
 
   gdb::byte_vector desc (sizeof (structsize) + buf->size ());
   memcpy (desc.data (), &structsize, sizeof (structsize));
+#if defined (__sparc__)
+  /* g++ 12.2.1 on sparc seems confused about the vector buf sizes.  */
+  DIAGNOSTIC_PUSH
+  DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+  DIAGNOSTIC_IGNORE_RESTRICT
+#endif
   memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
+#if defined (__sparc__)
+  DIAGNOSTIC_POP
+#endif
   return desc;
 }
 
index d3ff27bc008031ff9decd9656efead808f490a34..617943ae0d7ad85dca6913d2bc04e42402c36e36 100644 (file)
   DIAGNOSTIC_IGNORE ("-Wstringop-overread")
 #endif
 
+# if __GNUC__ >= 7
+# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW \
+  DIAGNOSTIC_IGNORE ("-Wstringop-overflow")
+#endif
+
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
 
 #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
 # endif
 
+#define DIAGNOSTIC_IGNORE_RESTRICT DIAGNOSTIC_IGNORE ("-Wrestrict")
 #endif
 
 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
 #endif
 
+#ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+# define DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
+#endif
+
 #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
 #endif