forked from OSchip/llvm-project
[flang] Fix/work around warnings from GCC 11
Apply part of a pending patch for GCC 11 warnings, and rework a piece of code, to dodge warnings on flag from GCC 11 build bots exposed by a recent patch. Applying without review to get bots working again; changes also tested against GCC 9.3.0.
This commit is contained in:
parent
c2b18a3cc5
commit
82cf35bc89
|
@ -80,22 +80,27 @@ inline constexpr Scalar<FTN_T> CastHostToFortran(const HostType<FTN_T> &x) {
|
|||
}
|
||||
}
|
||||
|
||||
// Scalar conversion utilities from F18 scalars to host scalars
|
||||
// Scalar conversion utilities from F18 scalars to host scalars.
|
||||
template <typename FTN_T>
|
||||
inline constexpr HostType<FTN_T> CastFortranToHost(const Scalar<FTN_T> &x) {
|
||||
static_assert(HostTypeExists<FTN_T>());
|
||||
if constexpr (FTN_T::category == TypeCategory::Complex &&
|
||||
sizeof(Scalar<FTN_T>) != sizeof(HostType<FTN_T>)) {
|
||||
// X87 is usually padded to 12 or 16bytes. Need to cast piecewise for
|
||||
// complex
|
||||
return HostType<FTN_T>{CastFortranToHost<typename FTN_T::Part>(x.REAL()),
|
||||
CastFortranToHost<typename FTN_T::Part>(x.AIMAG())};
|
||||
if constexpr (FTN_T::category == TypeCategory::Complex) {
|
||||
using FortranPartType = typename FTN_T::Part;
|
||||
return HostType<FTN_T>{CastFortranToHost<FortranPartType>(x.REAL()),
|
||||
CastFortranToHost<FortranPartType>(x.AIMAG())};
|
||||
} else if constexpr (std::is_same_v<FTN_T, Type<TypeCategory::Real, 10>>) {
|
||||
// x87 80-bit floating-point occupies 16 bytes as a C "long double";
|
||||
// copy the data to avoid a legitimate (but benign due to little-endianness)
|
||||
// warning from GCC >= 11.2.0.
|
||||
HostType<FTN_T> y;
|
||||
std::memcpy(&y, &x, sizeof x);
|
||||
return y;
|
||||
} else {
|
||||
static_assert(sizeof x == sizeof(HostType<FTN_T>));
|
||||
return *reinterpret_cast<const HostType<FTN_T> *>(&x);
|
||||
}
|
||||
}
|
||||
|
||||
// Defining the actual mapping
|
||||
template <> struct HostTypeHelper<Type<TypeCategory::Integer, 1>> {
|
||||
using Type = std::int8_t;
|
||||
};
|
||||
|
|
|
@ -234,13 +234,13 @@ int main(int argc, char **argv) {
|
|||
programPrefix = argv[0] + ": "s;
|
||||
|
||||
Fortran::parser::Options options;
|
||||
options.predefinitions.emplace_back("__flang__", "1");
|
||||
options.predefinitions.emplace_back("__flang_major__",
|
||||
FLANG_VERSION_MAJOR_STRING);
|
||||
options.predefinitions.emplace_back("__flang_minor__",
|
||||
FLANG_VERSION_MINOR_STRING);
|
||||
options.predefinitions.emplace_back("__flang_patchlevel__",
|
||||
FLANG_VERSION_PATCHLEVEL_STRING);
|
||||
options.predefinitions.emplace_back("__flang__"s, "1"s);
|
||||
options.predefinitions.emplace_back("__flang_major__"s,
|
||||
std::string{FLANG_VERSION_MAJOR_STRING});
|
||||
options.predefinitions.emplace_back("__flang_minor__"s,
|
||||
std::string{FLANG_VERSION_MINOR_STRING});
|
||||
options.predefinitions.emplace_back(
|
||||
"__flang_patchlevel__"s, std::string{FLANG_VERSION_PATCHLEVEL_STRING});
|
||||
|
||||
Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
|
||||
Fortran::parser::AllSources allSources;
|
||||
|
|
Loading…
Reference in New Issue