parser::AllocateObject and parser::PointerObject can be represented
as typed expressions once analyzed. This simplifies the work for parse-tree
consumers that work with typed expressions to deal with allocatable and
pointer objects such as lowering.
This change also makes it easier to add typedExpr in the future by
automatically handling nodes that have this member when possible.
Changes:
- Add a mutable TypedExpr typedExpr field to parser::PointerObject and parser::AllocateObject.
- Add a parser::HasTypedExpr<T> helper to better share code relating to typedExpr in the parse tree.
- Add hooks in semantics::ExprChecker for AllocateObject and PointerObject nodes, and use ExprOrVariable on it to analyze and set the tyedExpr field during expression analysis. This required adding overloads for AssumedTypeDummy.
- Update check-nullify.cpp and check-deallocate.cpp to not re-analyze the StructureComponent but to use the typedExpr field instead.
- Update dump/unparse to use HasTypedExpr and use the typedExpr when there is one.
This case could be simplified slightly:
This reduces the indentation and make the explicit return type unnecessary.