Calling "ASSOCATED(NULL()) was causing an internal check of the compiler to
fail.
I fixed this by changing the entry for "ASSOCIATED" in the intrinsics table to
accept "AnyPointer" which contains a new "KindCode" of "pointerType". I also
changed the function "FromActual()" which to return a typeless intrinsic when
called on a pointer, which duplicates its behavior for BOZ literals. This
required changing the analysis of procedure arguments. I wrote additional
tests to cover all of the code. This exposed an additional failing call to
CHECK() that I fixed.
I made several other changes:
- I implemented constant folding for ASSOCIATED().
- I fixed handling of NULL() in relational operations.
- I implemented semantic analysis for ASSOCIATED().
- I noticed that the semantics for ASSOCIATED() are similar to those for pointer assignment. So I extracted the code that pointer assignment uses for procedure pointer compatibility to a place where it could be used by the semantic analysis for ASSOCIATED().
- I couldn't figure out how to make the general semantic analysis for procedure arguments work with ASSOCIATED()'s second argument, which can be either a pointer or a target. So I stopped using normal semantic analysis for arguments for ASSOCIATED().
- I added tests for all of this.
Magic flag arguments should be avoided. If you want special-case handling of some input in some situation, consider adding a wrapper function with the magic that defaults to the original function otherwise. But maybe the new special behavior doesn't have to be special -- what would break if you just changed the treatment of NULL for all cases?