mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 18:47:52 +02:00
* handle rtti for sets with a size of 1 and 2 properly, resolves #8660
git-svn-id: trunk@7125 -
This commit is contained in:
parent
c6fb0d4cab
commit
c29455b111
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8153,6 +8153,7 @@ tests/webtbs/tw8513.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8525.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8573.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8615.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8660.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8664.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||
|
@ -506,7 +506,14 @@ implementation
|
||||
write_rtti_name(def);
|
||||
if (tf_requires_proper_alignment in target_info.flags) then
|
||||
current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
|
||||
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
|
||||
case def.size of
|
||||
1:
|
||||
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUByte));
|
||||
2:
|
||||
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUWord));
|
||||
4:
|
||||
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
|
||||
end;
|
||||
if (tf_requires_proper_alignment in target_info.flags) then
|
||||
current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
|
||||
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.elementdef,rt)));
|
||||
|
@ -2094,7 +2094,7 @@ implementation
|
||||
|
||||
function tsetdef.is_publishable : boolean;
|
||||
begin
|
||||
is_publishable:=(settype=smallset);
|
||||
is_publishable:=savesize in [1,2,4];
|
||||
end;
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ unit typinfo;
|
||||
case TTypeKind of
|
||||
tkUnKnown,tkLString,tkWString,tkAString,tkVariant:
|
||||
();
|
||||
tkInteger,tkChar,tkEnumeration,tkWChar:
|
||||
tkInteger,tkChar,tkEnumeration,tkWChar,tkSet:
|
||||
(OrdType : TOrdType;
|
||||
case TTypeKind of
|
||||
tkInteger,tkChar,tkEnumeration,tkBool,tkWChar : (
|
||||
@ -754,6 +754,7 @@ begin
|
||||
DataSize:=1;
|
||||
tkWChar:
|
||||
DataSize:=2;
|
||||
tkSet,
|
||||
tkEnumeration,
|
||||
tkInteger:
|
||||
begin
|
||||
|
34
tests/webtbs/tw8660.pp
Normal file
34
tests/webtbs/tw8660.pp
Normal file
@ -0,0 +1,34 @@
|
||||
program TestGetSetProp;
|
||||
{$APPTYPE CONSOLE}{$PACKSET 1}
|
||||
|
||||
uses TypInfo;
|
||||
|
||||
{$M+}
|
||||
type
|
||||
TEnum = (ckNormal, ckBusiness, ckVip, ckCorporate);
|
||||
TSet = set of TEnum;
|
||||
TClient = class
|
||||
private
|
||||
_Num: byte; // Works if Integer
|
||||
_St: TSet;
|
||||
published
|
||||
property Num: byte read _Num write _Num; // Works if Integer
|
||||
property St: TSet read _St write _St;
|
||||
end;
|
||||
|
||||
var
|
||||
C : TClient;
|
||||
V : TSet;
|
||||
begin
|
||||
C := TClient.Create;
|
||||
C.Num := 2;
|
||||
C.St := [ckVip, ckNormal]; // the numeric representation is 5
|
||||
V := C.St;
|
||||
writeln(sizeof(V), ' ', byte(V)); // It's OK
|
||||
writeln(sizeof(C.St), ' ', byte(C.St)); // It's OK
|
||||
if GetOrdProp(C, 'St')<>5 then
|
||||
halt(1);
|
||||
if GetSetProp(C, 'St')<>'ckNormal,ckVip' then
|
||||
halt(1);
|
||||
writeln('ok');
|
||||
end.
|
Loading…
Reference in New Issue
Block a user