[flang] Change complex type define in runtime for clang-cl

When compiling the runtime with a version of clang-cl newer than 12, we
define CMPLXF as __builtin_complex, which returns a float _Complex type.
This errors out in contexts where the result of CMPLXF is expected to be
a float_Complex_t. This is defined as _Fcomplex whenever _MSC_VER is
defined (and as float _Complex otherwise).

This patch defines float_Complex_t & friends as _Fcomplex only when
we're using "true" MSVC, and not just clang-pretending-to-be-MSVC. This
should only affect clang-cl >= 12.

Differential Revision: https://reviews.llvm.org/D110139
This commit is contained in:
Diana Picus 2021-09-21 08:57:38 +00:00
parent 47f79c6057
commit abbb0f901a
2 changed files with 4 additions and 4 deletions

View File

@ -23,7 +23,7 @@ struct CppComplexLongDouble {
/* Not all environments define CMPLXF, CMPLX, CMPLXL. */
#ifndef CMPLXF
#if __clang_major__ >= 12
#if defined(__clang_major__) && (__clang_major__ >= 12)
#define CMPLXF __builtin_complex
#else
static float_Complex_t CMPLXF(float r, float i) {
@ -39,7 +39,7 @@ static float_Complex_t CMPLXF(float r, float i) {
#endif
#ifndef CMPLX
#if __clang_major__ >= 12
#if defined(__clang_major__) && (__clang_major__ >= 12)
#define CMPLX __builtin_complex
#else
static double_Complex_t CMPLX(double r, double i) {
@ -55,7 +55,7 @@ static double_Complex_t CMPLX(double r, double i) {
#endif
#ifndef CMPLXL
#if __clang_major__ >= 12
#if defined(__clang_major__) && (__clang_major__ >= 12)
#define CMPLXL __builtin_complex
#else
static long_double_Complex_t CMPLXL(long double r, long double i) {

View File

@ -20,7 +20,7 @@
struct CppDescriptor; /* dummy type name for Fortran::runtime::Descriptor */
#ifdef _MSC_VER
#if defined(_MSC_VER) && !(defined(__clang_major__) && __clang_major__ >= 12)
typedef _Fcomplex float_Complex_t;
typedef _Dcomplex double_Complex_t;
typedef _Lcomplex long_double_Complex_t;