This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by Meinersbur on Sep 23 2020, 9:42 AM.

Details

Summary

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.

Diff Detail

Event Timeline

Meinersbur created this revision.Sep 23 2020, 9:42 AM
Herald added a project: Restricted Project. · View Herald Transcript
Meinersbur requested review of this revision.Sep 23 2020, 9:42 AM
klausler added inline comments.Sep 23 2020, 9:52 AM
flang/include/flang/Evaluate/constant.h
102

This change will restrict this constructor to work only with scalar items, I think.

Meinersbur retitled this revision from [flang][msvc] Avoid ctor initializer list population of vector. NFC. to [flang][msvc] Avoid templated initializer list initialization of vector. NFC..
Meinersbur edited the summary of this revision. (Show Details)

Just avoiding the template is sufficient.

klausler accepted this revision.Sep 23 2020, 10:49 AM
This revision is now accepted and ready to land.Sep 23 2020, 10:49 AM
This revision was landed with ongoing or failed builds.Sep 29 2020, 9:40 AM
This revision was automatically updated to reflect the committed changes.
Meinersbur added inline comments.Sep 29 2020, 10:34 AM
flang/include/flang/Evaluate/constant.h
102

I was trying to find out when this could be the case. However, I think it just moved any implicit conversion from type A to ELEMENT from happening from inside the ctor to the code that calls the ctor.