-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[flang] Initializers for proc pointers in module files #170349
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
Conversation
Default initializers for procedure pointer components are missing from module files; add them. Fixes llvm#170331.
|
@llvm/pr-subscribers-flang-semantics Author: Peter Klausler (klausler) ChangesDefault initializers for procedure pointer components are missing from module files; add them. Fixes #170331. Full diff: https://github.com/llvm/llvm-project/pull/170349.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 840b98dd42139..759b66ca27016 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -1069,6 +1069,15 @@ void ModFileWriter::PutProcEntity(llvm::raw_ostream &os, const Symbol &symbol) {
PutPassName(os, details.passName());
},
attrs);
+ if (symbol.owner().IsDerivedType()) {
+ if (const auto &init{details.init()}) {
+ if (const Symbol *symbol{*init}) {
+ os << "=>" << symbol->name();
+ } else {
+ os << "=>NULL()";
+ }
+ }
+ }
os << '\n';
}
diff --git a/flang/test/Semantics/modfile75.f90 b/flang/test/Semantics/modfile75.f90
new file mode 100644
index 0000000000000..e1f4db4051bbe
--- /dev/null
+++ b/flang/test/Semantics/modfile75.f90
@@ -0,0 +1,28 @@
+! RUN: %python %S/test_modfile.py %s %flang_fc1
+module m
+ type dt
+ procedure(sub), pointer, nopass :: p1 => sub
+ procedure(sub), pointer, nopass :: p2 => null()
+ procedure(sub), pointer, nopass :: p3
+ end type
+ procedure(sub), pointer :: p4 => sub
+ procedure(sub), pointer :: p5 => null()
+ contains
+ subroutine sub
+ end
+end
+
+!Expect: m.mod
+!module m
+!type::dt
+!procedure(sub),nopass,pointer::p1=>sub
+!procedure(sub),nopass,pointer::p2=>NULL()
+!procedure(sub),nopass,pointer::p3
+!end type
+!intrinsic::null
+!procedure(sub),pointer::p4
+!procedure(sub),pointer::p5
+!contains
+!subroutine sub()
+!end
+!end
|
|
@klausler This commit is causing issues on macOS: % git co 6a41ace~1
HEAD is now at 6f1e3c396812 [alpha.webkit.UncountedLocalVarsChecker] Ignore a VarDecl in "if" with trivial "then" (#171764)
% git stat
HEAD detached at 6f1e3c396812
nothing added to commit but untracked files present (use "git add" to track)
% git co 6a41ace
Previous HEAD position was 6f1e3c396812 [alpha.webkit.UncountedLocalVarsChecker] Ignore a VarDecl in "if" with trivial "then" (#171764)
HEAD is now at 6a41acef89b4 [flang] Initializers for proc pointers in module files (#170349)
% git stat
HEAD detached at 6a41acef89b4
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: flang/test/Semantics/modfile75.F90
no changes added to commit (use "git add" and/or "git commit -a")The newly introduced |
There is already a modfile75.F90 test, and the new test added in #170349 breaks git on macOS.
fhahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the test in 3afa68f, as this pretty much breaks any git operation on macOS
There is already a modfile75.F90 test, and the new test added in llvm/llvm-project#170349 breaks git on macOS.
Default initializers for procedure pointer components are missing from module files; add them.
Fixes #170331.