public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build
@ 2022-10-02 18:54 Jan-Benedict Glaw
  2022-10-03 13:49 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Jan-Benedict Glaw @ 2022-10-02 18:54 UTC (permalink / raw)
  To: binutils, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2600 bytes --]

Hi!

With GCC commit 0abb78dda084a14b3d955757c6431fff71c263f3 (PR81159),
gcc gained -Wself-move. GDB tests various warnings (and suppressing
them) in its unittests. -Wself-move is dealt for in case of clang, but
not (yet) for GCC, which breaks building GDB with recent GCC versions:

/usr/lib/gcc-snapshot/bin/g++ -x c++    -I. -I. -I./config -DLOCALEDIR="\"/tmp/gdb-m68k-linux/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../readline/readline/.. -I./../zlib  -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./../gnulib/import -I../gnulib/import -I./.. -I.. -I./../libbacktrace/ -I../libbacktrace/  -DTUI=1    -I./.. -pthread  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wstrict-null-sentinel -Wformat -Wformat-nonliteral -Werror -g -O2   -c -o unittests/environ-selftests.o -MT unittests/environ-selftests.o -MMD -MP -MF unittests/.deps/environ-selftests.Tpo unittests/environ-selftests.c
unittests/environ-selftests.c: In function 'void selftests::gdb_environ_tests::test_self_move()':
unittests/environ-selftests.c:228:7: error: moving 'env' of type 'gdb_environ' to itself [-Werror=self-move]
  228 |   env = std::move (env);
      |   ~~~~^~~~~~~~~~~~~~~~~
unittests/environ-selftests.c:228:7: note: remove 'std::move' call
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1896: unittests/environ-selftests.o] Error 1
make[1]: Leaving directory '/var/lib/laminar/run/gdb-m68k-linux/3/binutils-gdb/gdb'
make: *** [Makefile:13193: all-gdb] Error 2

I suggest the following patch.

Okay for HEAD?

Thanks,
  Jan-Benedict


include:
	* diagnostics.h (DIAGNOSTIC_IGNORE_SELF_MOVE): Define for GCC 13+.

diff --git a/include/diagnostics.h b/include/diagnostics.h
index 4161dff6abc..c1a2e8f520c 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -99,6 +99,10 @@
    DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
 # endif
 
+# if __GNUC__ >= 13
+#  define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
+# endif
+
 /* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch
    remains enabled at the error level even after a pop.  Therefore, don't
    use it for GCC < 5.  */
-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build
  2022-10-02 18:54 [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build Jan-Benedict Glaw
@ 2022-10-03 13:49 ` Nick Clifton
  2022-10-03 14:24   ` Jan-Benedict Glaw
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2022-10-03 13:49 UTC (permalink / raw)
  To: Jan-Benedict Glaw, binutils, gdb-patches

Hi Jan-Benedict,

> +# if __GNUC__ >= 13
> +#  define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
> +# endif

There appears to be a convention that the definition should be broken
up over two lines, ie:

   # if __GNUC__ >= 13
   #  define DIAGNOSTIC_IGNORE_SELF_MOVE \
      DIAGNOSTIC_IGNORE ("-Wself-move")
   # endif

Although DIAGNOSTIC_ERROR_SWITCH appears to be the exception to this rule.

More importantly however, you need to provide an empty definition at the
end of the file should the macro not be defined.  ie:

   #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
   # define DIAGNOSTIC_IGNORE_SELF_MOVE
   #endif

Cheers
   Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build
  2022-10-03 13:49 ` Nick Clifton
@ 2022-10-03 14:24   ` Jan-Benedict Glaw
  2022-10-03 14:36     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Jan-Benedict Glaw @ 2022-10-03 14:24 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

On Mon, 2022-10-03 14:49:55 +0100, Nick Clifton <nickc@redhat.com> wrote:
> Hi Jan-Benedict,
> 
> > +# if __GNUC__ >= 13
> > +#  define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
> > +# endif
> 
> There appears to be a convention that the definition should be broken
> up over two lines, ie:
> 
>   # if __GNUC__ >= 13
>   #  define DIAGNOSTIC_IGNORE_SELF_MOVE \
>      DIAGNOSTIC_IGNORE ("-Wself-move")
>   # endif

All the others would exceed some 80 columns and this macro, for the
`if defined (__clang__)` case, is also provided in one line.

> Although DIAGNOSTIC_ERROR_SWITCH appears to be the exception to this rule.

No, `DIAGNOSTIC_IGNORE_SELF_MOVE` is already existing (for __clang__)
and not wrapped there as well.

> More importantly however, you need to provide an empty definition at the
> end of the file should the macro not be defined.  ie:
> 
>   #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
>   # define DIAGNOSTIC_IGNORE_SELF_MOVE
>   #endif

That's already in place, see (after patch) at around line 115.

MfG, JBG

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build
  2022-10-03 14:24   ` Jan-Benedict Glaw
@ 2022-10-03 14:36     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2022-10-03 14:36 UTC (permalink / raw)
  To: Jan-Benedict Glaw; +Cc: binutils, gdb-patches

Hi Jan-Benedict,

   Me culpa for not reviewing properly.
   Patch approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-03 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 18:54 [PATCH] diagnostics.h: GCC 13 got -Wself-move, breaks GDB build Jan-Benedict Glaw
2022-10-03 13:49 ` Nick Clifton
2022-10-03 14:24   ` Jan-Benedict Glaw
2022-10-03 14:36     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).