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.
{$extended-pascal} program gale9 (output); const c = 2;
var y : type of c; {WRONG} {c is neither a variable-identifier or a parameter-identifier}
begin writeln('FAIL'); end.
{$extended-pascal} program gale10 (output);
var y: type of 3.14; {WRONG} {3.14 isn't an identifier at all let alone being either a variable-identifier or a parameter-identifier}
begin writeln('FAIL'); end.
{$extended-pascal} program gale11 (output);
var x: record f : integer; end; y: record f1: type of x.f; {WRONG} {x.f is a field-designator which isn't a variable-identifier or parameter-identifier} end;
begin writeln('FAIL'); end.
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).
The compiler I used was the latest version of Mac OS X GPC that Adriaan built and made available for downloading few weeks ago. The specs:
Reading specs from /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple-darwin8/3.4.5/specs Configured with: ../gcc-3.4.5/configure --enable-languages=pascal,c --enable-threads=posix --target=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --build=powerpc-apple-darwin8 --prefix=/Developer/Pascal/gpc345u2 Thread model: posix gpc version 20051116, based on gcc-3.4.5
Gale Paeper gpaeper@empirenet.com