[PATCH] D104779: [flang] Tweak the conditions for the GCC 7/libstdc++ workaround

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 04:41:53 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: klausler, clementval.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adjusts the workaround from D104731 <https://reviews.llvm.org/D104731>.

The issue lies in libstdc++'s classes, not GCC itself, and manifests
itself in the same way if building e.g. with clang while using
libstdc++ headers from GCC 7 (e.g. if building with Clang on Ubuntu 18.04,
while using the system default C++ library).

Therefore, change the condition to look for the version of libstdc++
instead of the compiler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104779

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


Index: flang/include/flang/Evaluate/type.h
===================================================================
--- flang/include/flang/Evaluate/type.h
+++ flang/include/flang/Evaluate/type.h
@@ -142,7 +142,7 @@
     return charLengthParamValue_;
   }
   constexpr std::optional<std::int64_t> knownLength() const {
-#if !__clang__ && __GNUC__ == 7
+#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 7
     if (knownLength_ < 0) {
       return std::nullopt;
     }
@@ -222,7 +222,7 @@
   TypeCategory category_{TypeCategory::Derived}; // overridable default
   int kind_{0};
   const semantics::ParamValue *charLengthParamValue_{nullptr};
-#if !__clang__ && __GNUC__ == 7
+#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 7
   // GCC 7's optional<> lacks a constexpr operator=
   std::int64_t knownLength_{-1};
 #else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104779.353932.patch
Type: text/x-patch
Size: 824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210623/8eb39647/attachment-0001.bin>


More information about the llvm-commits mailing list