Gale Paeper wrote:
ISO 10206, paragraph 6.4.9, requires a type-inquiry's type-inquiry-object be either a variable-name (i.e., [imported-interface-identifier '.']variable-identifier) or a parameter-identifier (with a defining point in the closest-containing formal-parameter-list). GPC has a few bugs in enforcing that requirement. As the following test programs demonstrate, GPC will erroneously also accept constant-identifiers, literal numbers, and field-designators as type-inquiry-objects.
I must admit I fixed this is my own code which I haven't found time to merge (and perhaps regression test). But I can confirm that my version correclty rejects your test programs (the former two always, the last one only in ISO mode, as its result is well-defined, just forbidden by ISO rules).
Note: I think the above test programs only show a small sample of what GPC will erroneously accept as a type-inquiry-object. If I'm not completely misunderstanding the compiler source code in this area, it looks like the compiler will accept nearly all, if not all, legal expressions as a type-inquiry-object which is a whole lot more than what my test programs are showing as wrong (as well as, a whole lot more than what ISO requirements allow for a type-inquiry-object).
You might want to run more extensive tests against my now code. I might have missed some cases you will find.
The following patch may work, but I've just ripped it out of other changes and didn't test it in isolation, so try with care ...
Frank