[flang-commits] [flang] [flang][Semantics] Fix ICE when compiling a mod file with parameter w… (PR #124285)
via flang-commits
flang-commits at lists.llvm.org
Fri Jan 24 07:19:29 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Jean-Didier PAILLEUX (JDPailleux)
<details>
<summary>Changes</summary>
…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
```
---
Full diff: https://github.com/llvm/llvm-project/pull/124285.diff
2 Files Affected:
- (modified) flang/lib/Semantics/mod-file.cpp (+7-1)
- (added) flang/test/Semantics/modfile_missing_type.f90 (+14)
``````````diff
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
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/124285
More information about the flang-commits
mailing list