This is an archive of the discontinued LLVM Phabricator instance.

[flang] Make f18 build with GCC 11.2.0 and with --std=c++20
AcceptedPublic

Authored by klausler on Dec 14 2021, 8:10 AM.

Details

Summary

C++20 deprecates the implicit access to the value of "this" in
a lambda closure with "[=]"; rewrite some as "[this]".

Address a legitimate, but benign, warning about overindexing when
converting REAL(10) 80-bit x87 floating-point constants to host
long doubles (when available), which GCC pads out to 16 bytes.

Add an explicit no-op constructor to Fortran::parser::Verbatim.
(It has worked fine without one until now, but now it seems necessary.)

Builds were verified out-of-tree against LLVM built with GCC 9.3.0
in both shared and static library linkage modes.

Diff Detail

Event Timeline

klausler created this revision.Dec 14 2021, 8:10 AM
klausler requested review of this revision.Dec 14 2021, 8:10 AM
klausler edited the summary of this revision. (Show Details)
rovka accepted this revision.Dec 15 2021, 3:55 AM
rovka added a subscriber: rovka.

Seems fine.

flang/CMakeLists.txt
113

Nit: How about if (NOT LLVM_CXX_STD EQUAL CMAKE_CXX_STANDARD)?

This revision is now accepted and ready to land.Dec 15 2021, 3:55 AM
klausler added inline comments.Dec 15 2021, 5:47 AM
flang/CMakeLists.txt
113

Only one of them has a "c++" prefix, so they would never compare equal.

rovka added inline comments.Dec 15 2021, 11:29 PM
flang/CMakeLists.txt
113

Right. Also, EQUAL is for "numbers", we should use STREQUAL: if (NOT LLVM_CXX_STD STREQUAL "c++${CMAKE_CXX_STANDARD}").

Michael K., would this change pose any trouble for MSVC builds?

klausler updated this revision to Diff 413949.Mar 8 2022, 3:09 PM

Extend patch to cover newly "upstreamed" code.

Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2022, 3:09 PM
Meinersbur accepted this revision.Mar 24 2022, 10:45 AM

Sorry for the long wait. msvc successfully compiles this with CMAKE_CXX_STANDARD set to 20 (which cmake translates to /std:c++20).

LGTM

flang/CMakeLists.txt
6–7

[suggestion] CMAKE_CXX_STANDARD is set by the user, so this will just overwrite it even if the user set it to CMAKE_CXX_STANDARD=20. Why not just check that the value is at least 17 and if not, override it with a warning like lined 117ff?

120

mvsc's option is /std:... (see https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170), so the string(REPLACE -std= ...) will not work.

LLVM_CXX_STD has been removed in rG2724d9e12960cc1d93eeabbfc9aa1bffffa041cc, so this code will never trigger anyway.

flang/lib/Lower/ConvertExpr.cpp
3732–3733

mvcs complains about arrLoad missing here, probably a result of changes this this patch.