gold patch committed: Revert -Wshadow patches
Ian Lance Taylor
iant@google.com
Mon Dec 14 19:58:00 GMT 2009
After checking with Nick, I've reverted the -Wshadow patches in the
gold and elfcpp directories.
The problem is that gcc's current -Wshadow warning is much too
aggressive for C++. A lot of code in gold looks like this:
class C
{
public:
C(const std::string& name)
: name_(name)
{ }
const std::string&
name() const
{ return this->name_; }
private:
std::string name_;
};
This code is fine, and the same value is consistently named "name"
which makes it clearer throughout. However, -Wshadow warns about the
use of "name" as the parameter to the constructor, because it shadows
the accessor function "name()" in the function. This warning is
pointless, because there is no possible confusion between a local
variable "name" and a method "name". Any attempt to use one for the
other will be a type error.
Changing the name of the parameter to avoid the pointless warning
makes the code less clear. In fact there is no good way to avoid the
-Wshadow warning.
So I have simply reverted the patch.
Ian
gold/ChangeLog:
2009-12-14 Ian Lance Taylor <iant@google.com>
Revert -Wshadow changes, all changes from:
2009-12-11 Doug Kwan <dougkwan@google.com>
2009-12-11 Nick Clifton <nickc@redhat.com>
* configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
elfcpp/ChangeLog:
2009-12-14 Ian Lance Taylor <iant@google.com>
* elfcpp_file.h: Revert last patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch.bz2
Type: application/x-bzip
Size: 57281 bytes
Desc: revert
URL: <https://sourceware.org/pipermail/binutils/attachments/20091214/9c929bc0/attachment.bin>
More information about the Binutils
mailing list