[flang-commits] [flang] d2d7a44 - [flang][msvc] Avoid templated initializer list initialization of vector. NFC.

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Tue Sep 29 09:40:49 PDT 2020


Author: Michael Kruse
Date: 2020-09-29T11:40:42-05:00
New Revision: d2d7a44facd2dc895d378f19233837147f587b6d

URL: https://github.com/llvm/llvm-project/commit/d2d7a44facd2dc895d378f19233837147f587b6d
DIFF: https://github.com/llvm/llvm-project/commit/d2d7a44facd2dc895d378f19233837147f587b6d.diff

LOG: [flang][msvc] Avoid templated initializer list initialization of vector. NFC.

The Microsoft compiler emits an error when populating the vector with a single element of a templated argument 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, we replace the templated constructor with one for the expected type. Conversion to the element type has to be done by the caller.

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: klausler

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index a25916f94ef7..a9f6e87c9db0 100644
--- a/flang/include/flang/Evaluate/constant.h
+++ b/flang/include/flang/Evaluate/constant.h
@@ -97,8 +97,7 @@ class ConstantBase : public ConstantBounds {
 
   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{})
+  ConstantBase(ELEMENT &&x, Result res = Result{})
       : result_{res}, values_{std::move(x)} {}
   ConstantBase(
       std::vector<Element> &&, ConstantSubscripts &&, Result = Result{});


        


More information about the flang-commits mailing list