[all-commits] [llvm/llvm-project] b65618: [flang][msvc] Avoid ReferenceVariantBase ctor ambi...

Michael Kruse via All-commits all-commits at lists.llvm.org
Wed Sep 30 18:54:27 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b656189e6a602aaf86714ccbf89d94f2ef05b644
      https://github.com/llvm/llvm-project/commit/b656189e6a602aaf86714ccbf89d94f2ef05b644
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2020-09-30 (Wed, 30 Sep 2020)

  Changed paths:
    M flang/include/flang/Lower/PFTBuilder.h
    M flang/lib/Lower/PFTBuilder.cpp

  Log Message:
  -----------
  [flang][msvc] Avoid ReferenceVariantBase ctor ambiguity. NFC.

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>.

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D88109




More information about the All-commits mailing list