From 1e3875ad36b810e9b075cfce21e4473cec392bf0 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 17 Feb 2004 15:57:49 +0000 Subject: [PATCH] - fix rtti generation for properties containing sl_vec - fix crash when overloaded operator is not available - fix record alignment for C style variant records --- compiler/fpcdefs.inc | 8 +++++++- compiler/pdecvar.pas | 12 ++++++++++-- compiler/pexpr.pas | 9 +++++++-- compiler/symdef.pas | 36 +++++++++++++++++++++++++++++++----- compiler/symtable.pas | 26 ++++++++++++++++++-------- 5 files changed, 73 insertions(+), 18 deletions(-) diff --git a/compiler/fpcdefs.inc b/compiler/fpcdefs.inc index 4c28ee75bb..30b8c970ee 100644 --- a/compiler/fpcdefs.inc +++ b/compiler/fpcdefs.inc @@ -60,6 +60,7 @@ {$define cpu64bit} {$define cpuextended} {$define cpufloat128} + {$define noopt} {$endif x86_64} {$ifdef alpha} @@ -94,7 +95,12 @@ { $Log$ - Revision 1.32 2004-02-09 22:48:45 florian + Revision 1.33 2004-02-17 15:57:49 peter + - fix rtti generation for properties containing sl_vec + - fix crash when overloaded operator is not available + - fix record alignment for C style variant records + + Revision 1.32 2004/02/09 22:48:45 florian * several fixes to parameter handling on arm Revision 1.31 2004/01/28 16:47:45 peter diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas index 1e2da2c0a8..ffb02aa244 100644 --- a/compiler/pdecvar.pas +++ b/compiler/pdecvar.pas @@ -1115,7 +1115,10 @@ implementation UnionSym:=tvarsym.create('$case',vs_value,uniontype); symtablestack:=symtablestack.next; { Align the offset where the union symtable is added } - usedalign:=used_align(maxalignment,aktalignment.recordalignmin,aktalignment.maxCrecordalign); + if (trecordsymtable(symtablestack).usefieldalignment=-1) then + usedalign:=used_align(maxalignment,aktalignment.recordalignmin,aktalignment.maxCrecordalign) + else + usedalign:=used_align(maxalignment,aktalignment.recordalignmin,aktalignment.recordalignmax); offset:=align(trecordsymtable(symtablestack).datasize,usedalign); trecordsymtable(symtablestack).datasize:=offset+unionsymtable.datasize; if maxalignment>trecordsymtable(symtablestack).fieldalignment then @@ -1135,7 +1138,12 @@ implementation end. { $Log$ - Revision 1.65 2004-02-12 15:54:03 peter + Revision 1.66 2004-02-17 15:57:49 peter + - fix rtti generation for properties containing sl_vec + - fix crash when overloaded operator is not available + - fix record alignment for C style variant records + + Revision 1.65 2004/02/12 15:54:03 peter * make extcycle is working again Revision 1.64 2004/02/03 22:32:54 peter diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 8ed4d5cf56..e5631f5cc0 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -213,7 +213,7 @@ implementation end; vecn : begin - addnode(tsubscriptnode(p).left); + addnode(tvecnode(p).left); if tvecnode(p).right.nodetype=ordconstn then sl.addconst(sl_vec,tordconstnode(tvecnode(p).right).value) else @@ -2525,7 +2525,12 @@ implementation end. { $Log$ - Revision 1.146 2004-02-03 22:32:54 peter + Revision 1.147 2004-02-17 15:57:49 peter + - fix rtti generation for properties containing sl_vec + - fix crash when overloaded operator is not available + - fix record alignment for C style variant records + + Revision 1.146 2004/02/03 22:32:54 peter * renamed xNNbittype to xNNinttype * renamed registers32 to registersint * replace some s32bit,u32bit with torddef([su]inttype).def.typ diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 59d05c0644..663978a174 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -1043,8 +1043,8 @@ implementation function tstoreddef.alignment : longint; begin - { normal alignment by default } - alignment:=0; + { natural alignment by default } + alignment:=size_2_align(savesize); end; @@ -5299,7 +5299,7 @@ implementation typvalue : byte; hp : psymlistitem; address : longint; - + def : tdef; begin if not(assigned(proc) and assigned(proc.firstsym)) then begin @@ -5310,9 +5310,30 @@ implementation begin address:=0; hp:=proc.firstsym; + def:=nil; while assigned(hp) do begin - inc(address,tvarsym(hp^.sym).fieldoffset); + case hp^.sltype of + sl_load : + begin + def:=tvarsym(hp^.sym).vartype.def; + inc(address,tvarsym(hp^.sym).fieldoffset); + end; + sl_subscript : + begin + if not(assigned(def) and (def.deftype=recorddef)) then + internalerror(200402171); + inc(address,tvarsym(hp^.sym).fieldoffset); + def:=tvarsym(hp^.sym).vartype.def; + end; + sl_vec : + begin + if not(assigned(def) and (def.deftype=arraydef)) then + internalerror(200402172); + def:=tarraydef(def).elementtype.def; + inc(address,def.size*hp^.value); + end; + end; hp:=hp^.next; end; rttiList.concat(Tai_const.Create_32bit(address)); @@ -6096,7 +6117,12 @@ implementation end. { $Log$ - Revision 1.218 2004-02-12 15:54:03 peter + Revision 1.219 2004-02-17 15:57:49 peter + - fix rtti generation for properties containing sl_vec + - fix crash when overloaded operator is not available + - fix record alignment for C style variant records + + Revision 1.218 2004/02/12 15:54:03 peter * make extcycle is working again Revision 1.217 2004/02/08 18:08:59 jonas diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 0ffef3a399..a002110fcf 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -1088,7 +1088,10 @@ implementation tvarsym(sym).fieldoffset:=align(datasize,varalignfield); datasize:=tvarsym(sym).fieldoffset+l; { Calc alignment needed for this record } - varalignrecord:=used_align(varalign,aktalignment.recordalignmin,aktalignment.recordalignmax); + if (usefieldalignment=-1) then + varalignrecord:=used_align(varalign,aktalignment.recordalignmin,aktalignment.maxCrecordalign) + else + varalignrecord:=used_align(varalign,aktalignment.recordalignmin,aktalignment.recordalignmax); recordalignment:=max(recordalignment,varalignrecord); end; @@ -2082,6 +2085,7 @@ implementation sv:cardinal; begin + result:=nil; st:=symtablestack; sv:=getspeedvalue(overloaded_names[op]); while st<>nil do @@ -2091,9 +2095,9 @@ implementation begin if sym.typ<>procsym then internalerror(200402031); - search_unary_operator:=sym.search_procdef_unary_operator(def); - if search_unary_operator<>nil then - break; + result:=sym.search_procdef_unary_operator(def); + if result<>nil then + exit; end; st:=st.next; end; @@ -2107,6 +2111,7 @@ implementation sv:cardinal; begin + result:=nil; st:=symtablestack; sv:=getspeedvalue(overloaded_names[op]); while st<>nil do @@ -2116,9 +2121,9 @@ implementation begin if sym.typ<>procsym then internalerror(200402031); - search_binary_operator:=sym.search_procdef_binary_operator(def1,def2); - if search_binary_operator<>nil then - break; + result:=sym.search_procdef_binary_operator(def1,def2); + if result<>nil then + exit; end; st:=st.next; end; @@ -2422,7 +2427,12 @@ implementation end. { $Log$ - Revision 1.137 2004-02-13 15:40:58 peter + Revision 1.138 2004-02-17 15:57:49 peter + - fix rtti generation for properties containing sl_vec + - fix crash when overloaded operator is not available + - fix record alignment for C style variant records + + Revision 1.137 2004/02/13 15:40:58 peter * fixed protected checking in withsymtable Revision 1.136 2004/02/11 19:59:06 peter