[flang] Improve handling of generics with same name as type or procedure
Create symbols for generics in a pre-pass over the specification part so it is easier to handle cases when they have the same name as a derived type or subprogram. This is done by calling `PreSpecificationConstruct` on each `SpecificationConstruct` of a specification part before we continue walking it. The generics symbols are created there and the same mechanism will be used to handle forward references to derived types. Report an error when the same name is used for a generic interface, derived type, and subprogram. Improve the error message issued when a procedure and generic interface have the same name but the procedure is not a specific of the generic. Change `SayAlreadyDeclared` to report the error on the second occurence of the name when possible. This can arise for declarations the are processed out of order, e.g. contained subprograms and generic interfaces. Avoid multiple "already declared" errors for the case when a contained subprogram has the same name as a declared entity. We first create the symbol with SubprogramNameDetails, then replace it with the entity (and report the error), then replace it with the real subprogram (and get the error again). By setting and checking the error flag we avoid the second error. Original-commit: flang-compiler/f18@48fc0767834154a7dbe9d5a964e603855ca88ab5 Reviewed-on: https://github.com/flang-compiler/f18/pull/614 Tree-same-pre-rewrite: false
Loading
Please sign in to comment