[flang-commits] [PATCH] D88163: [flang][msvc] Avoid ctor initializer list population of vector. NFC.

Michael Kruse via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Sep 23 09:42:04 PDT 2020


Meinersbur created this revision.
Meinersbur added reviewers: isuruf, DavidTruby, sscalpone, klausler, tskeith.
Meinersbur added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Meinersbur requested review of this revision.

The Microsoft compiler emits an error when populating the vector with a single element using the brace syntax. The error is:

  constant.h(102,1): error C2664: 'std::vector<Fortran::evaluate::value::Complex<...>, ...>::vector(std::initializer_list<_Ty>,const _Alloc &)': cannot convert argument 1 from 'initializer list' to 'std::initializer_list<_Ty>'

To work around this error, move pushing the first element of the vector into the constor body.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88163

Files:
  flang/include/flang/Evaluate/constant.h


Index: flang/include/flang/Evaluate/constant.h
===================================================================
--- flang/include/flang/Evaluate/constant.h
+++ flang/include/flang/Evaluate/constant.h
@@ -97,9 +97,9 @@
 
   template <typename A>
   ConstantBase(const A &x, Result res = Result{}) : result_{res}, values_{x} {}
-  template <typename A, typename = common::NoLvalue<A>>
-  ConstantBase(A &&x, Result res = Result{})
-      : result_{res}, values_{std::move(x)} {}
+  ConstantBase(ELEMENT &&x, Result res = Result{}) : result_{res} {
+    values_.push_back(std::move(x));
+  }
   ConstantBase(
       std::vector<Element> &&, ConstantSubscripts &&, Result = Result{});
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88163.293774.patch
Type: text/x-patch
Size: 686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200923/08395116/attachment.bin>


More information about the flang-commits mailing list