Skip to content

[Flang] Change sizeof argument name to "x" #130189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025
Merged

Conversation

akuhlens
Copy link
Contributor

@akuhlens akuhlens commented Mar 6, 2025

This closes #128610 by fixing the name of the argument to the sizeof function to be "x" and adds a test.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Mar 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 6, 2025

@llvm/pr-subscribers-flang-semantics

Author: Andre Kuhlenschmidt (akuhlens)

Changes

This closes #128610 by fixing the name of the argument to the sizeof function to be "x" and adds a test.


Full diff: https://github.com/llvm/llvm-project/pull/130189.diff

2 Files Affected:

  • (modified) flang/lib/Evaluate/intrinsics.cpp (+1-1)
  • (added) flang/test/Intrinsics/sizeof.f90 (+10)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index fe691e85ee011..65f17f06667dd 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -936,7 +936,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
             OptionalDIM, // unless array is assumed-size
             SizeDefaultKIND},
         KINDInt, Rank::scalar, IntrinsicClass::inquiryFunction},
-    {"sizeof", {{"a", AnyData, Rank::anyOrAssumedRank}}, SubscriptInt,
+    {"sizeof", {{"x", AnyData, Rank::anyOrAssumedRank}}, SubscriptInt,
         Rank::scalar, IntrinsicClass::inquiryFunction},
     {"spacing", {{"x", SameReal}}, SameReal},
     {"spread",
diff --git a/flang/test/Intrinsics/sizeof.f90 b/flang/test/Intrinsics/sizeof.f90
new file mode 100644
index 0000000000000..c7bd9788a3ce4
--- /dev/null
+++ b/flang/test/Intrinsics/sizeof.f90
@@ -0,0 +1,10 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+  character(len=20) :: a, b
+  if (sizeof(a) == sizeof(x=b)) then
+    print *, "pass"
+  else
+    print *, "fail"
+  end if
+  ERROR! unknown keyword argument to intrinsic 'sizeof'
+  print *, sizeof(a=a)
+end
\ No newline at end of file

@eugeneepshteyn
Copy link
Contributor

I reviewed and don't have any other comments. I'll defer to Peter to approve this.

@akuhlens akuhlens merged commit 3ab70e3 into llvm:main Mar 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flang] Compile error when argument keyword is used as argument to an extension sizeof intrinsic function
4 participants