[flang-commits] [flang] [flang] Fix symbol on module subroutine name with same name as generic (PR #67678)
via flang-commits
flang-commits at lists.llvm.org
Thu Sep 28 06:48:39 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
<details>
<summary>Changes</summary>
When a MODULE SUBROUTINE or MODULE FUNCTION is implemented in the same scope as its interface and appears in a generic with the same name, the parse::Name of the implementation was not correctly reset and remained the SubprogramNameDetails symbol after semantics, causing a crash in lowering that picks up the procedure symbols on the parser names.
Reset the parser::Name symbol before the new symbol is created.
---
Full diff: https://github.com/llvm/llvm-project/pull/67678.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+1)
- (modified) flang/test/Semantics/symbol28.f90 (+1-1)
``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 22e52521e188362..40f5ab9eb6e27ca 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4111,6 +4111,7 @@ bool SubprogramVisitor::BeginSubprogram(const parser::Name &name,
if (GenericDetails *
generic{DEREF(FindSymbol(name)).detailsIf<GenericDetails>()}) {
generic->clear_specific();
+ name.symbol = nullptr;
} else {
EraseSymbol(name);
}
diff --git a/flang/test/Semantics/symbol28.f90 b/flang/test/Semantics/symbol28.f90
index ab18749e6bd44b4..2bfe4e3a8c4c293 100644
--- a/flang/test/Semantics/symbol28.f90
+++ b/flang/test/Semantics/symbol28.f90
@@ -14,7 +14,7 @@ module subroutine s2 (j)
end subroutine
end interface
contains
- !DEF: /m1/s MODULE (Subroutine) SubprogramName
+ !DEF: /m1/s MODULE (Subroutine) Subprogram
module subroutine s
end subroutine
!REF: /m1/s2
``````````
</details>
https://github.com/llvm/llvm-project/pull/67678
More information about the flang-commits
mailing list