Silence GCC 9 error about deprecated implicit copy constructor.
authorCary Coutant <ccoutant@gmail.com>
Sat, 23 Jun 2018 01:19:51 +0000 (18:19 -0700)
committerCary Coutant <ccoutant@gmail.com>
Sat, 23 Jun 2018 01:19:51 +0000 (18:19 -0700)
Replacing push_back() with emplace_back() eliminates the calls to the
copy constructor, but I still had to provide explicit copy constructors
because of the call to vector::reserve(), which tries to instantiate them
even though they'll never actually be called when reserve() is called
on an empty vector.

gold/
* incremental.cc (Sized_incremental_binary::setup_readers): Use
emplace_back for GCC 5 and later.
* incremental.h (Incremental_binary::Input_reader): Provide copy
constructor.
(Sized_incremental_binary::Sized_input_reader): Likewise.

gold/ChangeLog
gold/incremental.cc
gold/incremental.h

index 623eb593f260091160a448f7420f5a24df071a97..10105137bdb78ceca36bc8ab076e0aa26c5c97a1 100644 (file)
@@ -1,3 +1,11 @@
+2018-06-22  Cary Coutant  <ccoutant@gmail.com>
+
+       * incremental.cc (Sized_incremental_binary::setup_readers): Use
+       emplace_back for GCC 5 and later.
+       * incremental.h (Incremental_binary::Input_reader): Provide copy
+       constructor.
+       (Sized_incremental_binary::Sized_input_reader): Likewise.
+
 2018-06-22  Cary Coutant  <ccoutant@gmail.com>
 
        PR gold/22914
index 21f060c945bc4603b60333d61f59547e9a1370ad..7558d14ff506e14972c2bfb6b6d5adfe3e355ff8 100644 (file)
@@ -311,7 +311,11 @@ Sized_incremental_binary<size, big_endian>::setup_readers()
   for (unsigned int i = 0; i < count; i++)
     {
       Input_entry_reader input_file = inputs.input_file(i);
+#if defined(__GNUC__) && __GNUC__ < 5
       this->input_entry_readers_.push_back(Sized_input_reader(input_file));
+#else
+      this->input_entry_readers_.emplace_back(input_file);
+#endif
       switch (input_file.type())
        {
        case INCREMENTAL_INPUT_OBJECT:
index 1c3fbe1147fc853a7689c7a18384bcfd33b61e16..b4694b33d07e97d7111cddc233d30de5681e6b06 100644 (file)
@@ -1368,6 +1368,9 @@ class Incremental_binary
     Input_reader()
     { }
 
+    Input_reader(const Input_reader&)
+    { }
+
     virtual
     ~Input_reader()
     { }
@@ -1708,6 +1711,10 @@ class Sized_incremental_binary : public Incremental_binary
       : Input_reader(), reader_(r)
     { }
 
+    Sized_input_reader(const Sized_input_reader& r)
+      : Input_reader(), reader_(r.reader_)
+    { }
+
     virtual
     ~Sized_input_reader()
     { }