[flang] Tweak the conditions for the GCC 7/libstdc++ workaround
authorMartin Storsjö <martin@martin.st>
Wed, 23 Jun 2021 11:37:01 +0000 (14:37 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 23 Jun 2021 20:19:32 +0000 (23:19 +0300)
This adjusts the workaround from 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.

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

flang/include/flang/Evaluate/type.h

index 6ab09f6..a57d810 100644 (file)
@@ -142,7 +142,7 @@ public:
     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 @@ private:
   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