[flang][semantics] make sure dynamic type inquiry functions take extensible or unlimited polymorphic types (#162931)
Adds error message when type is derived but not extensible and more
detailed error message when the type doesn't match.
fixes [#162712](https://github.com/llvm/llvm-project/issues/162712)