[flang-commits] [flang] [flang] Disabling REAL kinds must also disable their COMPLEX (PR #131353)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Mar 14 09:26:56 PDT 2025


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/131353

When disabling kinds of REAL in the TargetCharacteristics, one must also disable the corresponding kinds of COMPLEX.

Fixes https://github.com/llvm/llvm-project/issues/131088.

>From 8179b9e13cb83555a46f0922e5e2763c2d1fd499 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 14 Mar 2025 09:23:46 -0700
Subject: [PATCH] [flang] Disabling REAL kinds must also disable their COMPLEX

When disabling kinds of REAL in the TargetCharacteristics, one
must also disable the corresponding kinds of COMPLEX.

Fixes https://github.com/llvm/llvm-project/issues/131088.
---
 flang/include/flang/Tools/TargetSetup.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/flang/include/flang/Tools/TargetSetup.h b/flang/include/flang/Tools/TargetSetup.h
index ee05d891db353..e582215048250 100644
--- a/flang/include/flang/Tools/TargetSetup.h
+++ b/flang/include/flang/Tools/TargetSetup.h
@@ -49,6 +49,8 @@ namespace Fortran::tools {
   default:
     targetCharacteristics.DisableType(
         Fortran::common::TypeCategory::Real, /*kind=*/10);
+    targetCharacteristics.DisableType(
+        Fortran::common::TypeCategory::Complex, /*kind=*/10);
     break;
   }
 
@@ -62,11 +64,16 @@ namespace Fortran::tools {
   constexpr bool f128Support = false;
 #endif
 
-  if constexpr (!f128Support)
+  if constexpr (!f128Support) {
     targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
+    targetCharacteristics.DisableType(
+        Fortran::common::TypeCategory::Complex, 16);
+  }
 
-  for (auto realKind : targetOptions.disabledRealKinds)
+  for (auto realKind : targetOptions.disabledRealKinds) {
     targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
+    targetCharacteristics.DisableType(common::TypeCategory::Complex, realKind);
+  }
 
   for (auto intKind : targetOptions.disabledIntegerKinds)
     targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);



More information about the flang-commits mailing list