docopt.cpp icon indicating copy to clipboard operation
docopt.cpp copied to clipboard

Minor GCC build warning

Open markusl opened this issue 9 years ago • 1 comments

Hi. We have quite strict warnings used in our projects and I just recently run into this:

In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In constructor 'docopt::LeafPattern::LeafPattern(std::string, docopt::value)':
../vendor/docopt/docopt_private.h:84:3: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
   : fName(std::move(name)),


In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In constructor 'docopt::BranchPattern::BranchPattern(docopt::PatternList)':
../vendor/docopt/docopt_private.h:127:3: error: declaration of 'children' shadows a member of 'this' [-Werror=shadow]
   : fChildren(std::move(children))

In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In member function 'void docopt::BranchPattern::setChildren(docopt::PatternList)':
../vendor/docopt/docopt_private.h:164:42: error: declaration of 'children' shadows a member of 'this' [-Werror=shadow]
   void setChildren(PatternList children) {


In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In constructor 'docopt::Command::Command(std::string, docopt::value)':
../vendor/docopt/docopt_private.h:213:3: error: declaration of 'name' shadows a member of 'this' [-Werror=shadow]
   : Argument(std::move(name), std::move(v))
   ^

In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In constructor 'docopt::Option::Option(std::string, std::string, int, docopt::value)':
../vendor/docopt/docopt_private.h:230:3: error: declaration of 'longOption' shadows a member of 'this' [-Werror=shadow]
   : LeafPattern(longOption.empty() ? shortOption : longOption,
   ^

In file included from ../vendor/docopt/docopt.cpp:11:0:
../vendor/docopt/docopt_private.h: In constructor 'docopt::Option::Option(std::string, std::string, int, docopt::value)':
../vendor/docopt/docopt_private.h:230:3: error: declaration of 'shortOption' shadows a member of 'this' [-Werror=shadow]
   : LeafPattern(longOption_.empty() ? shortOption : longOption_,
   ^

../vendor/docopt/docopt.cpp: In member function 'virtual bool docopt::LeafPattern::match(docopt::PatternList&, std::vector<std::shared_ptr<docopt::LeafPattern> >&) const':
../vendor/docopt/docopt.cpp:118:7: error: declaration of 'match' shadows a member of 'this' [-Werror=shadow]
  auto match = single_match(left);
       ^

pt/CMakeFiles/docopt.dir/docopt.cpp.obj -c ../vendor/docopt/docopt.cpp
../vendor/docopt/docopt.cpp: In constructor 'Tokens::Tokens(std::vector<std::basic_string<char> >, bool)':
../vendor/docopt/docopt.cpp:450:2: error: declaration of 'isParsingArgv' shadows a member of 'this' [-Werror=shadow]
  : fTokens(std::move(tokens)),
  ^

Maybe you could use unique names for the parameter and the member variable? It would enable compiling the source with quite strict warning configuration.

Thanks, Markus

markusl avatar Feb 26 '16 09:02 markusl

Zero warnings is a great goal to have, and I think we should address these.

jaredgrubb avatar Nov 14 '16 17:11 jaredgrubb