mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 21:08:30 +02:00

symtype.pas, tdef: + add method "fullownerhierarchyname" which allows to retrieve the owner hierarchy name including procedure/function/method names + add method "fulltypename" which uses "fullownerhierarchyname" to return a full type name symdef.pas, tstoreddef: * implement "fullownerhierarchyname" (including caching of the result) pgenutil.pas, parse_generic_specialization_types_internal: * use "tdef.fulltypename" instead of "tdef.typename" to have unique values for each parsed type and thus for the specialization itself + tests git-svn-id: trunk@25175 -
67 lines
1.1 KiB
ObjectPascal
67 lines
1.1 KiB
ObjectPascal
program tgeneric94;
|
|
|
|
{$mode objfpc}
|
|
|
|
type
|
|
generic TTest<T> = record
|
|
f: T;
|
|
end;
|
|
|
|
TRec = record
|
|
x, y: LongInt;
|
|
end;
|
|
|
|
type
|
|
TTestTRec_Global = specialize TTest<TRec>;
|
|
const
|
|
TRecSize_Global = SizeOf(TRec);
|
|
|
|
procedure DoTest;
|
|
type
|
|
TRec = packed record
|
|
a, b: Byte;
|
|
end;
|
|
TTestTRec_DoTest = specialize TTest<TRec>;
|
|
const
|
|
TRecSize_DoTest = SizeOf(TRec);
|
|
|
|
procedure Nested(out aActual, aExpected: LongInt);
|
|
type
|
|
TRec = packed record
|
|
f1, f2: Word;
|
|
end;
|
|
TTestTRec_Nested = specialize TTest<TRec>;
|
|
const
|
|
TRecSize_Nested = SizeOf(TRec);
|
|
var
|
|
t: TTestTRec_Nested;
|
|
begin
|
|
aActual := SizeOf(t.f);
|
|
aExpected := TRecSize_Nested;
|
|
end;
|
|
|
|
procedure DoError(const aMessage: String);
|
|
begin
|
|
Writeln(aMessage);
|
|
ExitCode := 1;
|
|
Halt;
|
|
end;
|
|
|
|
var
|
|
tg: TTestTRec_Global;
|
|
tt: TTestTRec_DoTest;
|
|
act, expt: LongInt;
|
|
begin
|
|
if SizeOf(tg.f) <> TRecSize_Global then
|
|
DoError('Unexpected size of global TRec');
|
|
if SizeOf(tt.f) <> TRecSize_DoTest then
|
|
DoError('Unexpected size of DoTest TRec');
|
|
Nested(act, expt);
|
|
if act <> expt then
|
|
DoError('Unexpected size of Nested TRec');
|
|
end;
|
|
|
|
begin
|
|
DoTest;
|
|
end.
|