Skip to content

Commit

Permalink
[vcpkg] Fix gcc-9 warning (microsoft#7816)
Browse files Browse the repository at this point in the history
* drop one usage of span in export. Span is not appropriate for rvalues

* Add back reference

* Fix @ubsan 's comments
  • Loading branch information
cbezault authored Aug 21, 2019
1 parent 34a2654 commit 94ef325
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions toolsrc/src/vcpkg/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,26 +339,27 @@ namespace vcpkg::Export

struct OptionPair
{
const std::string& name;
const StringLiteral& name;
Optional<std::string>& out_opt;
};
const auto options_implies =
[&](const std::string& main_opt_name, bool main_opt, Span<const OptionPair> implying_opts) {
if (main_opt)
{
for (auto&& opt : implying_opts)
opt.out_opt = maybe_lookup(options.settings, opt.name);
}
else
{
for (auto&& opt : implying_opts)
Checks::check_exit(VCPKG_LINE_INFO,
!maybe_lookup(options.settings, opt.name),
"%s is only valid with %s",
opt.name,
main_opt_name);
}
};
const auto options_implies = [&](const StringLiteral& main_opt_name,
bool is_main_opt,
const std::initializer_list<OptionPair>& implying_opts) {
if (is_main_opt)
{
for (auto&& opt : implying_opts)
opt.out_opt = maybe_lookup(options.settings, opt.name);
}
else
{
for (auto&& opt : implying_opts)
Checks::check_exit(VCPKG_LINE_INFO,
!maybe_lookup(options.settings, opt.name),
"%s is only valid with %s",
opt.name,
main_opt_name);
}
};

#if defined(_MSC_VER) && _MSC_VER <= 1900
// there's a bug in VS 2015 that causes a bunch of "unreferenced local variable" warnings
Expand Down

0 comments on commit 94ef325

Please sign in to comment.