-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[flang] Assume unknown target of procedure pointer assignment is a pr… #66232
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ocedure When an previously unknown name appears as the target of an assignment to a known procedure pointer, create an external symbol for it rather than an implicitly-typed object symbol.
llvmbot
added
flang
Flang issues not falling into any other category
flang:semantics
labels
Sep 13, 2023
@llvm/pr-subscribers-flang-semantics Changes…ocedureWhen an previously unknown name appears as the target of an assignment to a known procedure pointer, create an external symbol for it rather than an implicitly-typed object symbol.Full diff: https://github.com/llvm/llvm-project/pull/66232.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 865c198424696a9..29cd107186fb5f0 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -8108,6 +8108,15 @@ bool ResolveNamesVisitor::Pre(const parser::PointerAssignmentStmt &x) { return false; } } + if (IsProcedurePointer(parser::GetLastName(dataRef).symbol) && + !FindSymbol(*name)) { + // Unknown target of procedure pointer must be an external procedure + Symbol &symbol{MakeSymbol( + context().globalScope(), name->source, Attrs{Attr::EXTERNAL})}; + Resolve(*name, symbol); + ConvertToProcEntity(symbol); + return false; + } } Walk(expr); return false; diff --git a/flang/test/Semantics/symbol31.f90 b/flang/test/Semantics/symbol31.f90 new file mode 100644 index 000000000000000..c8016cf9ec71b9b --- /dev/null +++ b/flang/test/Semantics/symbol31.f90 @@ -0,0 +1,7 @@ +! RUN: %python %S/test_symbols.py %s %flang_fc1 + !DEF: /MainProgram1/pptr EXTERNAL, POINTER ProcEntity + procedure(), pointer :: pptr + !REF: /MainProgram1/pptr + !DEF: /mustbeexternal EXTERNAL ProcEntity + pptr => mustbeexternal +end program |
vdonaldson
approved these changes
Sep 13, 2023
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
llvm#66232) …ocedure When an previously unknown name appears as the target of an assignment to a known procedure pointer, create an external symbol for it rather than an implicitly-typed object symbol.
klausler
added a commit
to klausler/llvm-project
that referenced
this pull request
Oct 30, 2023
A recent fix (llvm#66232) to interpret a hitherto unknown name whose first appearance is as the target of a procedure pointer initializer as an external procedure has led to some inapproprite warning messages if the name is later defined as an external subroutine ("X was already declared as an external"). Ensure that the EXTERNAL attribute is correctly noted as being implicit, and that it's okay that neither the Subroutine nor Function flag has yet been set for the implicit external.
klausler
added a commit
that referenced
this pull request
Oct 31, 2023
A recent fix (#66232) to interpret a hitherto unknown name whose first appearance is as the target of a procedure pointer initializer as an external procedure has led to some inapproprite warning messages if the name is later defined as an external subroutine ("X was already declared as an external"). Ensure that the EXTERNAL attribute is correctly noted as being implicit, and that it's okay that neither the Subroutine nor Function flag has yet been set for the implicit external.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ocedure
When an previously unknown name appears as the target of an assignment to a known procedure pointer, create an external symbol for it rather than an implicitly-typed object symbol.