This is an archive of the discontinued LLVM Phabricator instance.

[flang][msvc] Avoid ReferenceVariantBase ctor ambiguity. NFC.
ClosedPublic

Authored by Meinersbur on Sep 22 2020, 11:39 AM.

Details

Summary

Msvc reports the following error when a ReferenceVariantBase is constructed using an r-value reference or instantiated as std::vector template parameter. The error message is:

PFTBuilder.h(59,1): error C2665: 'std::variant<...>::variant': none of the 2 overloads could convert all the argument types
variant(1248,1): message : could be 'std::variant<...>::variant(std::variant<...> &&) noexcept(false)'
variant(1248,1): message : or       'std::variant<...>::variant(const std::variant<...> &) noexcept(false)'
PFTBuilder.h(59,1): message : while trying to match the argument list '(common::Reference<lower::pft::ReferenceVariantBase<false,...>>)'

Work around the ambiguity by only taking common::Reference arguments in the constructor. That is, conversion to common::Reference has to be done be the caller instead of being done inside the ctor. Unfortunately, with this change clang/gcc (but not msvc) insist on that the ReferenceVariantBase is stored in a std::initializer_list-initialized variable before being used, like being passed to a function or returned.

This patch is part of the series to make flang compilable with MS Visual Studio http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html.

Diff Detail

Event Timeline

Meinersbur created this revision.Sep 22 2020, 11:39 AM
Herald added a project: Restricted Project. · View Herald Transcript
  • Adhere flang variable naming scheme
  • Adhere clang variable naming scheme
DavidTruby accepted this revision.Sep 30 2020, 5:35 AM

LGTM. Not sure why msvc thinks these are ambiguous

This revision is now accepted and ready to land.Sep 30 2020, 5:35 AM
  • Compile fix (forgotten rename)
This revision was landed with ongoing or failed builds.Sep 30 2020, 6:54 PM
This revision was automatically updated to reflect the committed changes.