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

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
This commit is contained in:
Martin Storsjö 2021-06-23 14:37:01 +03:00
parent 84046ebd95
commit 2716c6faa4
1 changed files with 2 additions and 2 deletions

View 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