[flang-commits] [flang] [flang][Semantics] Fix ICE when compiling a mod file with parameter w… (PR #124285)
Jean-Didier PAILLEUX via flang-commits
flang-commits at lists.llvm.org
Fri Jan 24 07:18:37 PST 2025
https://github.com/JDPailleux created https://github.com/llvm/llvm-project/pull/124285
…ithout type specified
Fatal internal error occurred when compiling a mod file with a subroutine which contain a parameter with no
explicit type.
Ex:
```fortran
module inform
implicit none
interface normp
module subroutine normt( array, n, val,p )
integer siz
integer,optional::p
real*8 array(*)
real*8 val
end subroutine
end interface
end
```
>From c8509f14ae87b5826366005c342ede92b81f9415 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <jean-didier.pailleux at sipearl.com>
Date: Fri, 24 Jan 2025 15:17:05 +0100
Subject: [PATCH] [flang][Semantics] Fix ICE when compiling a mod file with
parameter without type specified
---
flang/lib/Semantics/mod-file.cpp | 8 +++++++-
flang/test/Semantics/modfile_missing_type.f90 | 14 ++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Semantics/modfile_missing_type.f90
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 51ff70c3ed8341..7a60e22de726e7 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -955,7 +955,13 @@ void ModFileWriter::PutObjectEntity(
}
}
PutEntity(
- os, symbol, [&]() { PutType(os, DEREF(symbol.GetType())); },
+ os, symbol,
+ [&]() {
+ // Need to check if there is a TYPE on this symbol to avoid any ICE
+ if (details.type()) {
+ PutType(os, DEREF(symbol.GetType()));
+ }
+ },
getSymbolAttrsToWrite(symbol));
PutShape(os, details.shape(), '(', ')');
PutShape(os, details.coshape(), '[', ']');
diff --git a/flang/test/Semantics/modfile_missing_type.f90 b/flang/test/Semantics/modfile_missing_type.f90
new file mode 100644
index 00000000000000..fda19372b8993f
--- /dev/null
+++ b/flang/test/Semantics/modfile_missing_type.f90
@@ -0,0 +1,14 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Test to check that this module can be compiled when an argument has no specified type
+module inform
+ implicit none
+ interface normp
+ module subroutine normt( array,n,val,p )
+ integer siz
+ integer,optional::p
+ real*8 array(*)
+ real*8 val
+ end subroutine
+ end interface
+end
+
More information about the flang-commits
mailing list