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

Diana Picus via flang-commits flang-commits at lists.llvm.org
Tue Sep 21 23:55:13 PDT 2021


Author: Diana Picus
Date: 2021-09-22T06:54:33Z
New Revision: abbb0f901ad85aaa06780deefbda9c0ee0c2c7a2

URL: https://github.com/llvm/llvm-project/commit/abbb0f901ad85aaa06780deefbda9c0ee0c2c7a2
DIFF: https://github.com/llvm/llvm-project/commit/abbb0f901ad85aaa06780deefbda9c0ee0c2c7a2.diff

LOG: [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

Added: 
    

Modified: 
    flang/runtime/complex-reduction.c
    flang/runtime/complex-reduction.h

Removed: 
    


################################################################################
diff  --git a/flang/runtime/complex-reduction.c b/flang/runtime/complex-reduction.c
index d0ca50f72d652..0e40c047adee6 100644
--- a/flang/runtime/complex-reduction.c
+++ b/flang/runtime/complex-reduction.c
@@ -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) {

diff  --git a/flang/runtime/complex-reduction.h b/flang/runtime/complex-reduction.h
index 5940ffff8cdd3..8e57f7c9149d2 100644
--- a/flang/runtime/complex-reduction.h
+++ b/flang/runtime/complex-reduction.h
@@ -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;


        


More information about the flang-commits mailing list