[PATCH] D98184: [flang] Fix bad dereference of NULLIFY pointer object
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 15:02:03 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfd7d8123a3b: [flang] Fix bad dereference of NULLIFY pointer object (authored by PeteSteinfeld).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98184/new/
https://reviews.llvm.org/D98184
Files:
flang/lib/Semantics/check-nullify.cpp
flang/test/Semantics/nullify02.f90
Index: flang/test/Semantics/nullify02.f90
===================================================================
--- flang/test/Semantics/nullify02.f90
+++ flang/test/Semantics/nullify02.f90
@@ -29,3 +29,21 @@
Nullify(maxvalue)
End Program
+
+! Make sure that the compiler doesn't crash when NULLIFY is used in a context
+! that has reported errors
+module badNullify
+ interface
+ module function ptrFun()
+ integer, pointer :: ptrFun
+ end function
+ end interface
+contains
+ !ERROR: 'ptrfun' was not declared a separate module procedure
+ module function ptrFun()
+ integer, pointer :: ptrFun
+ real :: realVar
+ nullify(ptrFun)
+ nullify(realVar)
+ end function
+end module
Index: flang/lib/Semantics/check-nullify.cpp
===================================================================
--- flang/lib/Semantics/check-nullify.cpp
+++ flang/lib/Semantics/check-nullify.cpp
@@ -26,17 +26,17 @@
std::visit(
common::visitors{
[&](const parser::Name &name) {
- const Symbol &symbol{DEREF(name.symbol)};
- if (context_.HasError(&symbol)) {
+ const Symbol *symbol{name.symbol};
+ if (context_.HasError(symbol)) {
// already reported an error
- } else if (!IsVariableName(symbol) && !IsProcName(symbol)) {
+ } else if (!IsVariableName(*symbol) && !IsProcName(*symbol)) {
messages.Say(name.source,
"name in NULLIFY statement must be a variable or procedure pointer name"_err_en_US);
- } else if (!IsPointer(symbol)) { // C951
+ } else if (!IsPointer(*symbol)) { // C951
messages.Say(name.source,
"name in NULLIFY statement must have the POINTER attribute"_err_en_US);
} else if (pure) {
- CheckDefinabilityInPureScope(messages, symbol, scope, *pure);
+ CheckDefinabilityInPureScope(messages, *symbol, scope, *pure);
}
},
[&](const parser::StructureComponent &structureComponent) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98184.329150.patch
Type: text/x-patch
Size: 2115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210308/c4d828bd/attachment.bin>
More information about the llvm-commits
mailing list