[flang-commits] [PATCH] D154380: [flang] Prevent lowering crash by properly updating symbol pointer
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jul 3 10:33:14 PDT 2023
klausler created this revision.
klausler added a reviewer: vzakhari.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
Kind of an edge case. When a MODULE FUNCTION or SUBROUTINE
interface is defined by a MODULE PROCEDURE in the same program
unit, ensure that the symbol table pointer in the parse tree is
updated to point to the SubprogramDetails symbol for the
interface, and not left pointing to what should soon become
a dead SubprogramNameDetails symbol.
https://reviews.llvm.org/D154380
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/symbol28.f90
Index: flang/test/Semantics/symbol28.f90
===================================================================
--- flang/test/Semantics/symbol28.f90
+++ flang/test/Semantics/symbol28.f90
@@ -43,7 +43,7 @@
end subroutine
end interface
contains
- !DEF: /m2/s MODULE SubprogramName
+ !REF:/m2/s
module procedure s
end procedure
!DEF: /m2/s2 MODULE, PUBLIC (Subroutine) Subprogram
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -4005,6 +4005,7 @@
// Convert the module procedure's interface into a subprogram.
SetScope(DEREF(symbol->scope()));
symbol->get<SubprogramDetails>().set_isInterface(false);
+ name.symbol = symbol;
} else {
// Copy the interface into a new subprogram scope.
EraseSymbol(name);
@@ -4025,7 +4026,8 @@
Symbol::Flag subpFlag, bool hasModulePrefix,
const parser::LanguageBindingSpec *bindingSpec,
const ProgramTree::EntryStmtList *entryStmts) {
- if (hasModulePrefix && currScope().IsGlobal()) { // C1547
+ if (hasModulePrefix && !currScope().IsModule() &&
+ !currScope().IsSubmodule()) { // C1547
Say(name,
"'%s' is a MODULE procedure which must be declared within a "
"MODULE or SUBMODULE"_err_en_US);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154380.536844.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230703/b5758d19/attachment-0001.bin>
More information about the flang-commits
mailing list