]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Fix build error in macroexp.c
authorTom de Vries <tdevries@suse.de>
Sat, 16 Jun 2018 16:39:30 +0000 (18:39 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 5 Jul 2018 09:23:46 +0000 (11:23 +0200)
When doing a combined build with the gcc and binutils-gdb repos, I run into
this build error in gdb:
...
gdb/macroexp.c: \
  In function ‘void get_next_token_for_substitution(macro_buffer*, \
  macro_buffer*, char**, macro_buffer*, char**, int*, bool*)’:
gdb/macroexp.c:925:17: error: \
  implicitly-declared ‘constexpr macro_buffer& \
  macro_buffer::operator=(const macro_buffer&)’ is deprecated \
  [-Werror=deprecated-copy]
       *token = *lookahead;
...

Wdeprecated-copy is a new gcc warning added after gcc 8.

This patch fixes the build error by adding an explicit copy operator to the
macro_buffer class.  I've added asserts to ensure that both the dest and src
of the copy are shared, in other words, neither is owner of the text pointer.

I've run the gdb testsuite on x86_64-linux and the asserts did not trigger.

2018-07-05  Tom de Vries  <tdevries@suse.de>

* macroexp.c (macro_buffer) <operator=>: New member function.

gdb/ChangeLog
gdb/macroexp.c

index 7bd0cc4f95e8f2cd5c2e976c18be44d3a71af9c8..39165f7cf4be1df3590b98bcdec55bac7ade02fc 100644 (file)
@@ -1,3 +1,7 @@
+2018-07-05  Tom de Vries  <tdevries@suse.de>
+
+       * macroexp.c (macro_buffer) <operator=>: New member function.
+
 2018-07-04  Tom Tromey  <tom@tromey.com>
 
        * darwin-nat.c (darwin_attach_pid): Use exit_inferior.
index 1fa37d2875b8467925c5c3f654be372c2b5b5711..36d0319f310b9430165c33a77959be60cb27f4b7 100644 (file)
@@ -112,6 +112,16 @@ struct macro_buffer
     shared = true;
   }
 
+  macro_buffer& operator= (const macro_buffer &src)
+  {
+    gdb_assert (src.shared);
+    gdb_assert (shared);
+    set_shared (src.text, src.len);
+    last_token = src.last_token;
+    is_identifier = src.is_identifier;
+    return *this;
+  }
+
   ~macro_buffer ()
   {
     if (! shared && size)