[flang-commits] [flang] [flang] Use correct dummy argument name X for IEEE_IS_NAN/IS_NEGATIVE/IS_NORMAL (PR #233757)

Cyrus Ding via flang-commits flang-commits at lists.llvm.org
Tue Oct 20 02:26:57 PDT 2026


https://github.com/dingcyrus created https://github.com/llvm/llvm-project/pull/233757

Also adds flang/test/Semantics/ieee_keywords.f90 covering positive X=, positional, and negative A= references.
Verified locally: the new test plus all existing IEEE Semantics/Evaluate/Lower tests pass; flang/test/Semantics, flang/test/Evaluate, flang/test/Lower/Intrinsics show no diff against an unpatched baseline.

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

>From c10859067c97c9d704d5718e48d493492e5f67dd Mon Sep 17 00:00:00 2001
From: Cyrus Ding <785101675 at qq.com>
Date: Tue, 20 Oct 2026 17:20:08 +0800
Subject: [PATCH] [flang] Use correct dummy argument name X for
 IEEE_IS_NAN/IS_NEGATIVE/IS_NORMAL

The IEEE_ARITHMETIC classification inquiry functions IEEE_IS_NAN,
IEEE_IS_NEGATIVE and IEEE_IS_NORMAL take a mandatory dummy argument
named X in the standard, but flang's generic intrinsic table declared
it as "a", so keyword references like IEEE_IS_NAN(X = v) were
rejected. Align the three entries with IEEE_NEXT_UP/DOWN which
already use "x". IEEE_INT/IEEE_REAL are intentionally left untouched.

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

Co-Authored-By: Claude Code <noreply at anthropic.com>
---
 flang/lib/Evaluate/intrinsics.cpp      |  6 +++---
 flang/test/Semantics/ieee_keywords.f90 | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 flang/test/Semantics/ieee_keywords.f90

diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index f7ea85a455ac2e..5ba4e73198b882 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1094,9 +1094,9 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
     {"__builtin_ieee_int",
         {{"a", AnyFloating}, {"round", IeeeRoundType}, DefaultingKIND},
         KINDInt},
-    {"__builtin_ieee_is_nan", {{"a", AnyFloating}}, DefaultLogical},
-    {"__builtin_ieee_is_negative", {{"a", AnyFloating}}, DefaultLogical},
-    {"__builtin_ieee_is_normal", {{"a", AnyFloating}}, DefaultLogical},
+    {"__builtin_ieee_is_nan", {{"x", AnyFloating}}, DefaultLogical},
+    {"__builtin_ieee_is_negative", {{"x", AnyFloating}}, DefaultLogical},
+    {"__builtin_ieee_is_normal", {{"x", AnyFloating}}, DefaultLogical},
     {"__builtin_ieee_next_after", {{"x", SameReal}, {"y", AnyReal}}, SameReal},
     {"__builtin_ieee_next_down", {{"x", SameReal}}, SameReal},
     {"__builtin_ieee_next_up", {{"x", SameReal}}, SameReal},
diff --git a/flang/test/Semantics/ieee_keywords.f90 b/flang/test/Semantics/ieee_keywords.f90
new file mode 100644
index 00000000000000..07d4f6edbc4f51
--- /dev/null
+++ b/flang/test/Semantics/ieee_keywords.f90
@@ -0,0 +1,17 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! The mandatory dummy argument of the IEEE_ARITHMETIC classification inquiry
+! functions is named X in the standard, not A.
+use ieee_arithmetic, only : ieee_is_nan, ieee_is_negative, ieee_is_normal
+implicit none
+real :: v = 1.0
+print *, ieee_is_nan(v)
+print *, ieee_is_nan(X = v)
+print *, ieee_is_negative(X = v)
+print *, ieee_is_normal(X = v)
+!ERROR: unknown keyword argument to intrinsic '__builtin_ieee_is_nan'
+print *, ieee_is_nan(A = v)
+!ERROR: unknown keyword argument to intrinsic '__builtin_ieee_is_negative'
+print *, ieee_is_negative(A = v)
+!ERROR: unknown keyword argument to intrinsic '__builtin_ieee_is_normal'
+print *, ieee_is_normal(A = v)
+end



More information about the flang-commits mailing list