[flang] Fix bad dereference of NULLIFY pointer object
authorPeter Steinfeld <psteinfeld@nvidia.com>
Mon, 8 Mar 2021 16:21:30 +0000 (08:21 -0800)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Mon, 8 Mar 2021 23:01:36 +0000 (15:01 -0800)
commitcfd7d8123a3b1e77343763ac2b62124bfcffe6d6
tree3e965c129e17d828e8254663e47909d48aeacdd6
parent535a4192a9d19ef5d474f1d6bfa1ab9f08b2b1c7
[flang] Fix bad dereference of NULLIFY pointer object

When we have a subprogram that has been determined to contain errors, we do not
perform name resolution on its execution part.  In this case, if the subprogram
contains a NULLIFY statement, the parser::Name of a pointer object in a NULLIFY
statement will not have had name resolution performed on it.  Thus, its symbol
will not have been set.  Later, however, we do semantic checking on the NULLIFY
statement.  The code that did this assumed that the parser::Name of the
pointer object was non-null.

I fixed this by just removing the null pointer check for the "symbol" member of
the "parser::Name" of the pointer object when doing semantic checking for
NULLIFY statements.  I also added a test that will make the compiler crash
without this change.

Differential Revision: https://reviews.llvm.org/D98184
flang/lib/Semantics/check-nullify.cpp
flang/test/Semantics/nullify02.f90