[fpc-devel] Typed addresses by default

Florian Klaempfl florian at freepascal.org
Wed Oct 4 22:01:13 CEST 2006


Micha Nelissen schrieb:
> Hi,
> 
> Attached patch modifies compiler to enable typed addresses ({$T+}) for
> fpc and objfpc modes by default. It fixes the rtl and compiler to
> compile again. Most of these fixes are simple pointer to array vs.
> pointer to element of array changes, but some reveal ugly code IMHO ;-).
> 
> Anyway, any opinions on whether it is useful to enforce typed addresses
> by default ?

For me, it is ok, to apply it in objfpc and fpc mode. T- enforces sloppy 
programming which we don't want after all ;)

> 
> Micha
> 
> 
> ------------------------------------------------------------------------
> 
> Index: rtl/unix/unix.pp
> ===================================================================
> --- rtl/unix/unix.pp	(revision 4765)
> +++ rtl/unix/unix.pp	(working copy)
> @@ -858,7 +858,7 @@
>        end;
>       textrec(f).bufptr:=@textrec(f).buffer;
>     {Save the process ID - needed when closing }
> -     pl:=@(textrec(f).userdata[2]);
> +     pl:=pcint(@(textrec(f).userdata[2]));
>       pl^:=pid;
>       textrec(f).closefunc:=@PCloseText;
>     end;
> @@ -971,7 +971,7 @@
>          f:=pipi;
>        end;
>     {Save the process ID - needed when closing }
> -     pl:=@(filerec(f).userdata[2]);
> +     pl:=pcint(@(filerec(f).userdata[2]));
>       pl^:=pid;
>     end;
>   POpen:=0;
> @@ -1034,11 +1034,11 @@
>       close(pipo);
>       close(pipi);
>       {Save the process ID - needed when closing }
> -     pl:=@(textrec(StreamIn).userdata[2]);
> +     pl:=pcint(@(textrec(StreamIn).userdata[2]));
>       pl^:=pid;
>       textrec(StreamIn).closefunc:=@PCloseText;
>       {Save the process ID - needed when closing }
> -     pl:=@(textrec(StreamOut).userdata[2]);
> +     pl:=pcint(@(textrec(StreamOut).userdata[2]));
>       pl^:=pid;
>       textrec(StreamOut).closefunc:=@PCloseText;
>       AssignStream:=Pid;
> @@ -1124,15 +1124,15 @@
>      Close(PipeOut);
>      Close(PipeIn);
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamIn).userdata[2]);
> +    pl := pcint(@(TextRec(StreamIn).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamIn).closefunc := @PCloseText;
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamOut).userdata[2]);
> +    pl := pcint(@(TextRec(StreamOut).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamOut).closefunc := @PCloseText;
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamErr).userdata[2]);
> +    pl := pcint(@(TextRec(StreamErr).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamErr).closefunc := @PCloseText;
>      AssignStream := pid;
> Index: rtl/unix/cthreads.pp
> ===================================================================
> --- rtl/unix/cthreads.pp	(revision 4765)
> +++ rtl/unix/cthreads.pp	(working copy)
> @@ -223,7 +223,7 @@
>        // don't create detached, we need to be able to join (waitfor) on
>        // the newly created thread!
>        //pthread_attr_setdetachstate(@thread_attr, PTHREAD_CREATE_DETACHED);
> -      if pthread_create(@threadid, @thread_attr, @ThreadMain,ti) <> 0 then begin
> +      if pthread_create(ppthread_t(@threadid), @thread_attr, @ThreadMain,ti) <> 0 then begin
>          threadid := TThreadID(0);
>        end;
>        CBeginThread:=threadid;
> Index: rtl/unix/cwstring.pp
> ===================================================================
> --- rtl/unix/cwstring.pp	(revision 4765)
> +++ rtl/unix/cwstring.pp	(working copy)
> @@ -153,7 +153,7 @@
>      destpos:=pchar(dest);
>      outleft:=outlength;
>      lockiconv(lock_wide2ansi);
> -    while iconv(iconv_wide2ansi, at srcpos, at srclen, at destpos, at outleft)=size_t(-1) do
> +    while iconv(iconv_wide2ansi,ppchar(@srcpos), at srclen, at destpos, at outleft)=size_t(-1) do
>        begin
>          case fpgetCerrno of
>            ESysEILSEQ:
> @@ -210,7 +210,7 @@
>      destpos:=pchar(dest);
>      outleft:=outlength*2;
>      lockiconv(lock_ansi2wide);
> -    while iconv(iconv_ansi2wide, at srcpos, at len, at destpos, at outleft)=size_t(-1) do
> +    while iconv(iconv_ansi2wide, at srcpos,psize(@len), at destpos, at outleft)=size_t(-1) do
>        begin
>          case fpgetCerrno of
>           ESysEILSEQ:
> @@ -286,7 +286,7 @@
>      destpos:=pchar(dest);
>      outleft:=outlength*4;
>      lockiconv(lock_ansi2ucs4);
> -    while iconv(iconv_ansi2ucs4, at srcpos, at len, at destpos, at outleft)=size_t(-1) do
> +    while iconv(iconv_ansi2ucs4, at srcpos,psize(@len), at destpos, at outleft)=size_t(-1) do
>        begin
>          case fpgetCerrno of
>            ESysE2BIG:
> Index: rtl/unix/sysdir.inc
> ===================================================================
> --- rtl/unix/sysdir.inc	(revision 4765)
> +++ rtl/unix/sysdir.inc	(working copy)
> @@ -32,7 +32,7 @@
>     exit;
>    Move(s[1], Buffer, Length(s));
>    Buffer[Length(s)] := #0;
> -  If Fpmkdir(@buffer, MODE_MKDIR)<0 Then
> +  If Fpmkdir(@buffer[0], MODE_MKDIR)<0 Then
>     Errno2Inoutres
>    Else
>     InOutRes:=0;
> @@ -49,7 +49,7 @@
>     exit;
>    Move(s[1], Buffer, Length(s));
>    Buffer[Length(s)] := #0;
> -  If Fprmdir(@buffer)<0 Then
> +  If Fprmdir(@buffer[0])<0 Then
>     Errno2Inoutres
>    Else
>     InOutRes:=0;
> @@ -64,7 +64,7 @@
>     exit;
>    Move(s[1], Buffer, Length(s));
>    Buffer[Length(s)] := #0;
> -  If Fpchdir(@buffer)<0 Then
> +  If Fpchdir(@buffer[0])<0 Then
>     Errno2Inoutres
>    Else
>     InOutRes:=0;
> @@ -93,7 +93,7 @@
>  begin
>    dir:='';
>  {$ifdef usegetcwd}
> - if Fpgetcwd(@buf,sizeof(buf))<>nil then
> + if Fpgetcwd(@buf[0],sizeof(buf))<>nil then
>     dir:=strpas(buf);
>  {$else}
>    thedir:='';
> Index: rtl/unix/dos.pp
> ===================================================================
> --- rtl/unix/dos.pp	(revision 4765)
> +++ rtl/unix/dos.pp	(working copy)
> @@ -648,7 +648,7 @@
>             Move(f.SearchSpec[1], DirName[0], f.NamePos);
>             DirName[f.NamePos] := #0;
>           End;
> -        f.DirPtr := fpopendir(@(DirName));
> +        f.DirPtr := fpopendir(@DirName[0]);
>          If f.DirPtr <> nil Then
>           begin
>             ArrayPos:=FindLastUsed;
> @@ -673,7 +673,7 @@
>       if p=nil then
>        FName:=''
>       else
> -      FName:=Strpas(@p^.d_name);
> +      FName:=Strpas(@p^.d_name[0]);
>       If FName='' Then
>        Finished:=True
>       Else
> @@ -767,7 +767,7 @@
>    LinAttr : longint;
>  Begin
>    DosError:=0;
> -  if FPStat(@textrec(f).name,info)<0 then
> +  if FPStat(@textrec(f).name[0],info)<0 then
>     begin
>       Attr:=0;
>       DosError:=3;
> @@ -779,7 +779,7 @@
>     Attr:=$10
>    else
>     Attr:=$0;
> -  if fpAccess(@textrec(f).name,W_OK)<0 then
> +  if fpAccess(@textrec(f).name[0],W_OK)<0 then
>     Attr:=Attr or $1;
>    if filerec(f).name[0]='.' then
>     Attr:=Attr or $2;
> @@ -816,7 +816,7 @@
>        UnPackTime(Time,DT);
>        modtime:=DTToUnixDate(DT);
>      end;
> -  if fputime(@filerec(f).name, at utim)<0 then
> +  if fputime(@filerec(f).name[0], at utim)<0 then
>      begin
>        Time:=0;
>        doserror:=3;
> Index: rtl/linux/gpm.pp
> ===================================================================
> --- rtl/linux/gpm.pp	(revision 4765)
> +++ rtl/linux/gpm.pp	(working copy)
> @@ -534,7 +534,7 @@
>    strcopy(addr.path, GPM_NODE_CTL);
>    i:=sizeof(addr.family)+length(GPM_NODE_CTL);
>  
> -  if fpconnect(gpm_fd, at addr,i)<0 then
> +  if fpconnect(gpm_fd,psockaddr(@addr),i)<0 then
>      begin
>  {         gpm_report(GPM_PR_INFO,GPM_MESS_DOUBLE_S,GPM_NODE_CTL,strerror(errno));}
>        {Well, try to open a chr device called /dev/gpmctl. This should
> Index: rtl/linux/unxfunc.inc
> ===================================================================
> --- rtl/linux/unxfunc.inc	(revision 4765)
> +++ rtl/linux/unxfunc.inc	(working copy)
> @@ -33,13 +33,13 @@
>  
>  Function PClose(Var F:text) :cint;
>  var
> -  pl  : ^cint;
> +  pl  : pcint;
>    res : cint;
>    pid : cint;
>  begin
>    fpclose(Textrec(F).Handle);
>  { closed our side, Now wait for the other - this appears to be needed ?? }
> -  pl:=@(textrec(f).userdata[2]);
> +  pl:=pcint(@(textrec(f).userdata[2]));
>    { avoid alignment error on sparc }
>    move(pl^,pid,sizeof(pid));
>    fpwaitpid(pid, at res,0);
> @@ -54,7 +54,7 @@
>  begin
>    fpclose(filerec(F).Handle);
>  { closed our side, Now wait for the other - this appears to be needed ?? }
> -  pl:=@(filerec(f).userdata[2]);
> +  pl:=pcint(@(filerec(f).userdata[2]));
>    { avoid alignment error on sparc }
>    move(pl^,pid,sizeof(pid));
>    fpwaitpid(pid, at res,0);
> Index: rtl/linux/oldlinux.pp
> ===================================================================
> --- rtl/linux/oldlinux.pp	(revision 4765)
> +++ rtl/linux/oldlinux.pp	(working copy)
> @@ -2792,7 +2792,7 @@
>    sr.reg2:=Textrec(F).Handle;
>    SysCall (syscall_nr_close,sr);
>  { closed our side, Now wait for the other - this appears to be needed ?? }
> -  pl:=@(textrec(f).userdata[2]);
> +  pl:=plongint(@(textrec(f).userdata[2]));
>    waitpid(pl^, at res,0);
>    pclose:=res shr 8;
>  end;
> @@ -2807,7 +2807,7 @@
>    sr.reg2:=FileRec(F).Handle;
>    SysCall (Syscall_nr_close,sr);
>  { closed our side, Now wait for the other - this appears to be needed ?? }
> -  pl:=@(filerec(f).userdata[2]);
> +  pl:=plongint(@(filerec(f).userdata[2]));
>    waitpid(pl^, at res,0);
>    pclose:=res shr 8;
>  end;
> @@ -4516,7 +4516,7 @@
>          textrec(f).bufptr:=@textrec(f).buffer;
>        end;
>     {Save the process ID - needed when closing }
> -     pl:=@(textrec(f).userdata[2]);
> +     pl:=plongint(@(textrec(f).userdata[2]));
>       pl^:=pid;
>       textrec(f).closefunc:=@PCloseText;
>     end;
> @@ -4602,7 +4602,7 @@
>          f:=pipi;
>        end;
>     {Save the process ID - needed when closing }
> -     pl:=@(filerec(f).userdata[2]);
> +     pl:=plongint(@(filerec(f).userdata[2]));
>       pl^:=pid;
>     end;
>  end;
> @@ -4666,11 +4666,11 @@
>       close(pipo);
>       close(pipi);
>       {Save the process ID - needed when closing }
> -     pl:=@(textrec(StreamIn).userdata[2]);
> +     pl:=plongint(@(textrec(StreamIn).userdata[2]));
>       pl^:=pid;
>       textrec(StreamIn).closefunc:=@PCloseText;
>       {Save the process ID - needed when closing }
> -     pl:=@(textrec(StreamOut).userdata[2]);
> +     pl:=plongint(@(textrec(StreamOut).userdata[2]));
>       pl^:=pid;
>       textrec(StreamOut).closefunc:=@PCloseText;
>       AssignStream:=Pid;
> @@ -4757,15 +4757,15 @@
>      Close(PipeOut);
>      Close(PipeIn);
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamIn).userdata[2]);
> +    pl := plongint(@(TextRec(StreamIn).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamIn).closefunc := @PCloseText;
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamOut).userdata[2]);
> +    pl := plongint(@(TextRec(StreamOut).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamOut).closefunc := @PCloseText;
>      // Save the process ID - needed when closing
> -    pl := @(TextRec(StreamErr).userdata[2]);
> +    pl := plongint(@(TextRec(StreamErr).userdata[2]));
>      pl^ := pid;
>      TextRec(StreamErr).closefunc := @PCloseText;
>      AssignStream := pid;
> @@ -5059,15 +5059,15 @@
>      d:=Readdir(dirstream);
>      while (d<>nil) do
>       begin
> -       name:=n+'/'+strpas(@(d^.name));
> +       name:=n+'/'+strpas(@(d^.name[0]));
>         fstat(name,st);
>         if linuxerror=0 then
>          begin
>            if ((st.mode and $E000)=$4000) and  { if it is a directory }
> -             (strpas(@(d^.name))<>'.') and    { but not ., .. and fd subdirs }
> -             (strpas(@(d^.name))<>'..') and
> -             (strpas(@(d^.name))<>'') and
> -             (strpas(@(d^.name))<>'fd') then
> +             (strpas(@(d^.name[0]))<>'.') and    { but not ., .. and fd subdirs }
> +             (strpas(@(d^.name[0]))<>'..') and
> +             (strpas(@(d^.name[0]))<>'') and
> +             (strpas(@(d^.name[0]))<>'fd') then
>             begin                      {we found a directory, search inside it}
>               if mysearch(name) then
>                begin                 {the device is here}
> Index: rtl/inc/mouse.inc
> ===================================================================
> --- rtl/inc/mouse.inc	(revision 4765)
> +++ rtl/inc/mouse.inc	(working copy)
> @@ -25,8 +25,8 @@
>  Procedure ClearMouseEventQueue;
>  
>  begin
> -  PendingMouseHead:=@PendingMouseEvent;
> -  PendingMouseTail:=@PendingMouseEvent;
> +  PendingMouseHead:=@PendingMouseEvent[0];
> +  PendingMouseTail:=@PendingMouseEvent[0];
>    PendingMouseEvents:=0;
>    FillChar(LastMouseEvent,sizeof(TMouseEvent),0);
>  end;
> @@ -119,7 +119,7 @@
>    MouseEvent:=PendingMouseHead^;
>    inc(PendingMouseHead);
>    if PtrInt(PendingMouseHead)=Ptrint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
> -   PendingMouseHead:=@PendingMouseEvent;
> +   PendingMouseHead:=@PendingMouseEvent[0];
>    dec(PendingMouseEvents);
>    if (LastMouseEvent.x<>MouseEvent.x) or
>       (LastMouseEvent.y<>MouseEvent.y) then
> @@ -162,7 +162,7 @@
>      PendingMouseTail^:=MouseEvent;
>      inc(PendingMouseTail);
>      if PtrInt(PendingMouseTail)=Ptrint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
> -      PendingMouseTail:=@PendingMouseEvent;
> +      PendingMouseTail:=@PendingMouseEvent[0];
>      inc(PendingMouseEvents);
>      end
>    else
> Index: rtl/inc/variants.pp
> ===================================================================
> --- rtl/inc/variants.pp	(revision 4765)
> +++ rtl/inc/variants.pp	(working copy)
> @@ -3481,7 +3481,7 @@
>  
>  function FindVarData(const V: Variant): PVarData;
>    begin
> -    result:=@V;
> +    result:=pvardata(@V);
>      while result^.vtype=varVariant or VarByRef do
>        result:=PVarData(result^.VPointer);
>    end;
> Index: rtl/inc/text.inc
> ===================================================================
> --- rtl/inc/text.inc	(revision 4765)
> +++ rtl/inc/text.inc	(working copy)
> @@ -939,7 +939,7 @@
>       inc(p);}
>      while p<maxp do
>        begin
> -        q:=@stop_chars;
> +        q:=@stop_chars[0];
>          while (q^<>#0) and (p^<>q^) do
>            inc(q);
>          if p^=q^ then 
> Index: rtl/inc/objects.pp
> ===================================================================
> --- rtl/inc/objects.pp	(revision 4765)
> +++ rtl/inc/objects.pp	(working copy)
> @@ -981,13 +981,14 @@
>  FUNCTION TObject.Is_Object(P:Pointer):Boolean;
>  TYPE
>     PVMT=^VMT;
> +   PPVMT=^PVMT;
>     VMT=RECORD
>       Size,NegSize:Longint;
>       ParentLink:PVMT;
>     END;
> -VAR SP:^PVMT; Q:PVMT;
> +VAR SP:PPVMT; Q:PVMT;
>  BEGIN
> -   SP:=@SELF;
> +   SP:=PPVMT(@SELF);
>     Q:=SP^;
>     Is_Object:=False;
>     While Q<>Nil Do Begin
> Index: rtl/inc/objpas.inc
> ===================================================================
> --- rtl/inc/objpas.inc	(revision 4765)
> +++ rtl/inc/objpas.inc	(working copy)
> @@ -303,7 +303,7 @@
>                 FieldTable := PFieldTable((Pointer(CurClassType) + vmtFieldTable)^);
>                 if FieldTable <> nil then
>                 begin
> -                 FieldInfo := @FieldTable^.Fields;
> +                 FieldInfo := @FieldTable^.Fields[0];
>                   for i := 0 to FieldTable^.FieldCount - 1 do
>                   begin
>                     if UpCase(FieldInfo^.Name) = UName then
> @@ -311,7 +311,7 @@
>                       fieldaddress := Pointer(Self) + FieldInfo^.FieldOffset;
>                       exit;
>                     end;
> -                   FieldInfo := @FieldInfo^.Name + 1 + Length(FieldInfo^.Name);
> +                   FieldInfo := PFieldInfo(PByte(@FieldInfo^.Name) + 1 + Length(FieldInfo^.Name));
>  {$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
>                     { align to largest field of TFieldInfo }
>                     FieldInfo := Align(FieldInfo, SizeOf(PtrUInt));
> Index: rtl/inc/sockovl.inc
> ===================================================================
> --- rtl/inc/sockovl.inc	(revision 4765)
> +++ rtl/inc/sockovl.inc	(working copy)
> @@ -42,7 +42,7 @@
>  Function RecvFrom(Sock : Longint; Var Buf; Buflen,Flags : Longint; Var Addr ; var AddrLen :longint) : longint;
>  
>  begin
> -  RecvFrom:=fprecvfrom(Sock, at buf,buflen,flags, at Addr, at AddrLen);
> +  RecvFrom:=fprecvfrom(Sock, at buf,buflen,flags, at Addr,psocklen(@AddrLen));
>  end;
>  
>  Function Bind(Sock:Longint;Const Addr;AddrLen:Longint):Boolean;
> @@ -57,7 +57,7 @@
>  
>  Function Accept(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
>  begin
> -  Accept:=fpaccept(sock, at addr, at addrlen);
> +  Accept:=fpaccept(sock, at addr,psocklen(@addrlen));
>  end;
>  
>  Function Connect(Sock:Longint;Const Addr;Addrlen:Longint): boolean;
> @@ -73,12 +73,12 @@
>  
>  Function GetSocketName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
>  begin
> -  GetSocketName:=fpgetsockname(sock, at addr, at addrlen);
> +  GetSocketName:=fpgetsockname(sock, at addr,psocklen(@addrlen));
>  end;
>  
>  Function GetPeerName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
>  begin
> -  GetPeerName:=fpgetPeerName(sock, at addr, at addrlen);
> +  GetPeerName:=fpgetPeerName(sock, at addr,psocklen(@addrlen));
>  end;
>  
>  Function SetSocketOptions(Sock,Level,OptName:Longint;const OptVal;optlen:longint):Longint;
> @@ -88,12 +88,12 @@
>  
>  Function GetSocketOptions(Sock,Level,OptName:Longint;Var OptVal;Var optlen:longint):Longint;
>  begin
> -  GetSocketOptions:=fpgetsockopt(Sock,Level,OptName, at OptVal, at OptLen);
> +  GetSocketOptions:=fpgetsockopt(Sock,Level,OptName, at OptVal,psocklen(@OptLen));
>  end;
>  
>  Function SocketPair(Domain,SocketType,Protocol:Longint;var Pair:TSockArray):Longint;
>  begin
> -  SocketPair:=fpsocketpair(domain,sockettype,protocol, at pair);
> +  SocketPair:=fpsocketpair(domain,sockettype,protocol, at pair[1]);
>  end;
>  
>  {******************************************************************************
> Index: rtl/inc/dynarr.inc
> ===================================================================
> --- rtl/inc/dynarr.inc	(revision 4765)
> +++ rtl/inc/dynarr.inc	(working copy)
> @@ -340,18 +340,18 @@
>  
>  procedure DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: SizeInt; lengthVec: PSizeInt);
>    var
> -    preallocated : array[0..10] of PSizeInt;
> +    preallocated : array[0..10] of SizeInt;
>      i : SizeInt;
>      p : PSizeInt;
>    begin
>      if dimCnt<=length(preallocated) then
> -      p:=@preallocated
> +      p:=@preallocated[0]
>      else
>        getmem(p,sizeof(SizeInt)*dimCnt);
>      for i:=0 to dimCnt-1 do
>        p[i]:=lengthVec[dimCnt-1-i];
>      int_dynarray_setlength(a,typeInfo,dimCnt,p);
> -    if p<>@preallocated then
> +    if p<>@preallocated[0] then
>        freemem(p);
>    end;
>  
> Index: rtl/objpas/sysutils/sysstr.inc
> ===================================================================
> --- rtl/objpas/sysutils/sysstr.inc	(revision 4765)
> +++ rtl/objpas/sysutils/sysstr.inc	(working copy)
> @@ -1921,7 +1921,7 @@
>  
>  Begin
>    Buf[FloatToTextFmt(@Buf[0],Value,Pchar(Format))]:=#0;
> -  Result:=StrPas(@Buf);
> +  Result:=StrPas(@Buf[0]);
>  End;
>  
>  function FormatCurr(const Format: string; Value: Currency): string;
> Index: rtl/objpas/sysutils/dati.inc
> ===================================================================
> --- rtl/objpas/sysutils/dati.inc	(revision 4765)
> +++ rtl/objpas/sysutils/dati.inc	(working copy)
> @@ -708,10 +708,10 @@
>    DecodeDateFully(DateTime, Year, Month, Day, DayOfWeek);
>    DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
>    ResultLen := 0;
> -  ResultCurrent := @ResultBuffer;
> +  ResultCurrent := @ResultBuffer[0];
>    StoreFormat(FormatStr);
>    ResultBuffer[ResultLen] := #0;
> -  result := StrPas(@ResultBuffer);
> +  result := StrPas(@ResultBuffer[0]);
>  end ;
>  
>  {   DateTimeToString formats DateTime to the given format in FormatStr   }
> Index: rtl/objpas/sysutils/sysuintf.inc
> ===================================================================
> --- rtl/objpas/sysutils/sysuintf.inc	(revision 4765)
> +++ rtl/objpas/sysutils/sysuintf.inc	(working copy)
> @@ -73,19 +73,20 @@
>      end;
>    end;
>  
> -  function HexByte(p: PChar): Char;
> +  function HexByte(p: PChar): Byte;
>    begin
> -    Result:=Char((HexChar(p[0]) shl 4) + HexChar(p[1]));
> +    Result:=(HexChar(p[0]) shl 4) + HexChar(p[1]);
>    end;
>  
>  var
>    i: integer;
> -  src, dest: PChar;
> +  src: PChar;
> +  dest: PByte;
>  begin
>    if ((Length(S)<>38) or
>        (s[1]<>'{')) then
>      raise EConvertError.CreateFmt(SInvalidGUID, [s]);
> -  dest:=@Result;
> +  dest:=@Result.D4[0];
>    src:=PChar(s);
>    inc(src);
>    for i:=0 to 3 do
> Index: rtl/objpas/typinfo.pp
> ===================================================================
> --- rtl/objpas/typinfo.pp	(revision 4765)
> +++ rtl/objpas/typinfo.pp	(working copy)
> @@ -500,7 +500,7 @@
>        hp:=GetTypeData(Typeinfo);
>        // the class info rtti the property rtti follows immediatly
>        pd:=aligntoptr(pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1));
> -      Result:=@pd^.PropList;
> +      Result:=PPropInfo(@pd^.PropList);
>        for i:=1 to pd^.PropCount do
>          begin
>            // found a property of that name ?
> Index: compiler/cutils.pas
> ===================================================================
> --- compiler/cutils.pas	(revision 4765)
> +++ compiler/cutils.pas	(working copy)
> @@ -842,7 +842,7 @@
>        i:=1;
>        len:=0;
>        varcounter:=0;
> -      varptr:=@varvaluedata;
> +      varptr:=@varvaluedata[0];
>        while i<=length(s) do
>          begin
>            if (s[i]='$') and (i<length(s)) then
> @@ -863,7 +863,7 @@
>                     inc(i);
>                   until s[i]='}';
>                   varvalues[varcounter]:=Pstring(varptr);
> -                 if varptr>@varvaluedata+maxdata then
> +                 if varptr>@varvaluedata[0]+maxdata then
>                     internalerrorproc(200411152);
>                   Pstring(varptr)^:=get_var_value(varname);
>                   inc(len,length(Pstring(varptr)^));
> Index: compiler/cp8859_1.pas
> ===================================================================
> --- compiler/cp8859_1.pas	(revision 4765)
> +++ compiler/cp8859_1.pas	(working copy)
> @@ -270,7 +270,7 @@
>  
>       unicodemap : tunicodemap = (
>         cpname : '8859-1';
> -       map : @map;
> +       map : @map[0];
>         lastchar : 255;
>         next : nil;
>         internalmap : true
> Index: compiler/cp850.pas
> ===================================================================
> --- compiler/cp850.pas	(revision 4765)
> +++ compiler/cp850.pas	(working copy)
> @@ -270,7 +270,7 @@
>  
>       unicodemap : tunicodemap = (
>         cpname : 'cp850';
> -       map : @map;
> +       map : @map[0];
>         lastchar : 255;
>         next : nil;
>         internalmap : true
> Index: compiler/globals.pas
> ===================================================================
> --- compiler/globals.pas	(revision 4765)
> +++ compiler/globals.pas	(working copy)
> @@ -1816,7 +1816,7 @@
>        var
>          p: pbyte;
>        begin
> -        p := @r;
> +        p := pbyte(@r);
>  {$ifdef CPU_ARM}
>          inc(p,4);
>  {$else}   
> Index: compiler/ncal.pas
> ===================================================================
> --- compiler/ncal.pas	(revision 4765)
> +++ compiler/ncal.pas	(working copy)
> @@ -1411,12 +1411,14 @@
>          result:=vmttree;
>        end;
>  
> +    type
> +      pcallparanode = ^tcallparanode;
>  
>      procedure tcallnode.bind_parasym;
>        var
>          i        : integer;
>          pt       : tcallparanode;
> -        oldppt   : ^tcallparanode;
> +        oldppt   : pcallparanode;
>          varargspara,
>          currpara : tparavarsym;
>          used_by_callnode : boolean;
> @@ -1425,14 +1427,14 @@
>          temp         : ttempcreatenode;
>        begin
>          pt:=tcallparanode(left);
> -        oldppt:=@left;
> +        oldppt:=pcallparanode(@left);
>  
>          { flag all callparanodes that belong to the varargs }
>          i:=paralength;
>          while (i>procdefinition.maxparacount) do
>            begin
>              include(pt.callparaflags,cpf_varargs_para);
> -            oldppt:=@pt.right;
> +            oldppt:=pcallparanode(@pt.right);
>              pt:=tcallparanode(pt.right);
>              dec(i);
>            end;
> @@ -1518,7 +1520,7 @@
>             if not assigned(pt) then
>               internalerror(200310052);
>             pt.parasym:=currpara;
> -           oldppt:=@pt.right;
> +           oldppt:=pcallparanode(@pt.right);
>             pt:=tcallparanode(pt.right);
>           end;
>  
> Index: compiler/cp437.pas
> ===================================================================
> --- compiler/cp437.pas	(revision 4765)
> +++ compiler/cp437.pas	(working copy)
> @@ -270,7 +270,7 @@
>  
>       unicodemap : tunicodemap = (
>         cpname : 'cp437';
> -       map : @map;
> +       map : @map[0];
>         lastchar : 255;
>         next : nil;
>         internalmap : true
> Index: compiler/scanner.pas
> ===================================================================
> --- compiler/scanner.pas	(revision 4765)
> +++ compiler/scanner.pas	(working copy)
> @@ -269,12 +269,14 @@
>           if s='TP' then
>            aktmodeswitches:=tpmodeswitches
>          else
> -         if s='FPC' then
> -          aktmodeswitches:=fpcmodeswitches
> -        else
> -         if s='OBJFPC' then
> -          aktmodeswitches:=objfpcmodeswitches
> -        else
> +         if s='FPC' then begin
> +          aktmodeswitches:=fpcmodeswitches;
> +          include(aktlocalswitches, cs_typed_addresses);
> +        end else
> +         if s='OBJFPC' then begin
> +          aktmodeswitches:=objfpcmodeswitches;
> +          include(aktlocalswitches, cs_typed_addresses);
> +        end else
>           if s='GPC' then
>            aktmodeswitches:=gpcmodeswitches
>          else
> Index: compiler/systems/t_emx.pas
> ===================================================================
> --- compiler/systems/t_emx.pas	(revision 4765)
> +++ compiler/systems/t_emx.pas	(working copy)
> @@ -115,7 +115,7 @@
>          end;
>  
>  var aout_str_size:longint;
> -    aout_str_tab:array[0..2047] of byte;
> +    aout_str_tab:array[0..2047] of char;
>      aout_sym_count:longint;
>      aout_sym_tab:array[0..5] of nlist;
>  
> @@ -258,7 +258,7 @@
>      blockwrite(out_file,aout_text,aout_text_size);
>      blockwrite(out_file,aout_treloc_tab,sizeof(reloc)*aout_treloc_count);
>      blockwrite(out_file,aout_sym_tab,sizeof(aout_sym_tab[0])*aout_sym_count);
> -    longint((@aout_str_tab)^):=aout_str_size;
> +    plongint(@aout_str_tab)^:=aout_str_size;
>      blockwrite(out_file,aout_str_tab,aout_str_size);
>  end;
>  
> Index: compiler/systems/t_os2.pas
> ===================================================================
> --- compiler/systems/t_os2.pas	(revision 4765)
> +++ compiler/systems/t_os2.pas	(working copy)
> @@ -115,7 +115,7 @@
>          end;
>  
>  var aout_str_size:longint;
> -    aout_str_tab:array[0..2047] of byte;
> +    aout_str_tab:array[0..2047] of char;
>      aout_sym_count:longint;
>      aout_sym_tab:array[0..5] of nlist;
>  
> @@ -258,7 +258,7 @@
>      blockwrite(out_file,aout_text,aout_text_size);
>      blockwrite(out_file,aout_treloc_tab,sizeof(reloc)*aout_treloc_count);
>      blockwrite(out_file,aout_sym_tab,sizeof(aout_sym_tab[0])*aout_sym_count);
> -    longint((@aout_str_tab)^):=aout_str_size;
> +    plongint(@aout_str_tab)^:=aout_str_size;
>      blockwrite(out_file,aout_str_tab,aout_str_size);
>  end;
>  
> Index: compiler/x86/aasmcpu.pas
> ===================================================================
> --- compiler/x86/aasmcpu.pas	(revision 4765)
> +++ compiler/x86/aasmcpu.pas	(working copy)
> @@ -1550,7 +1550,7 @@
>          ea_data : ea;
>        begin
>          len:=0;
> -        codes:=@p^.code;
> +        codes:=@p^.code[0];
>          repeat
>            c:=ord(codes^);
>            inc(codes);
> @@ -1707,7 +1707,7 @@
>           $0, $A, $A, $B, $8, $4);
>        var
>          c : byte;
> -        pb,
> +        pb : pbyte;
>          codes : pchar;
>          bytes : array[0..3] of byte;
>          rfield,
> @@ -1936,16 +1936,16 @@
>                     if not process_ea(oper[opidx]^,ea_data,rfield) then
>                      Message(asmw_e_invalid_effective_address);
>  
> -                   pb:=@bytes;
> -                   pb^:=chr(ea_data.modrm);
> +                   pb:=@bytes[0];
> +                   pb^:=ea_data.modrm;
>                     inc(pb);
>                     if ea_data.sib_present then
>                      begin
> -                      pb^:=chr(ea_data.sib);
> +                      pb^:=ea_data.sib;
>                        inc(pb);
>                      end;
>  
> -                   s:=pb-pchar(@bytes);
> +                   s:=pb- at bytes[0];
>                     objdata.writebytes(bytes,s);
>  
>                     case ea_data.bytes of
> Index: compiler/nadd.pas
> ===================================================================
> --- compiler/nadd.pas	(revision 4765)
> +++ compiler/nadd.pas	(working copy)
> @@ -606,8 +606,8 @@
>                c2[0]:=char(byte(tordconstnode(right).value));
>                c2[1]:=#0;
>                l2:=1;
> -              s1:=@c1;
> -              s2:=@c2;
> +              s1:=@c1[0];
> +              s2:=@c2[0];
>                concatstrings:=true;
>             end
>           else if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
> @@ -616,7 +616,7 @@
>                l1:=tstringconstnode(left).len;
>                c2[0]:=char(byte(tordconstnode(right).value));
>                c2[1]:=#0;
> -              s2:=@c2;
> +              s2:=@c2[0];
>                l2:=1;
>                concatstrings:=true;
>             end
> @@ -625,7 +625,7 @@
>                c1[0]:=char(byte(tordconstnode(left).value));
>                c1[1]:=#0;
>                l1:=1;
> -              s1:=@c1;
> +              s1:=@c1[0];
>                s2:=tstringconstnode(right).value_str;
>                l2:=tstringconstnode(right).len;
>                concatstrings:=true;
> Index: compiler/utils/fpcmkcfg.pp
> ===================================================================
> --- compiler/utils/fpcmkcfg.pp	(revision 4765)
> +++ compiler/utils/fpcmkcfg.pp	(working copy)
> @@ -82,7 +82,7 @@
>    AddToList(List,'BUILDDATE',DateToStr(Date));
>    AddToList(List,'BUILDTIME',TimeToStr(Time));
>    Cfg:=TStringList.Create;
> -  Cfg.Text:=StrPas(Addr(DefaultConfig));
> +  Cfg.Text:=StrPas(Addr(DefaultConfig[0][1]));
>  end;
>  
>  Procedure Done;
> @@ -190,9 +190,9 @@
>      begin
>        case IDEBuildin of
>          1:
> -           Cfg.Text:=StrPas(Addr(fpcfg));
> +           Cfg.Text:=StrPas(Addr(fpcfg[0][1]));
>          2:
> -           Cfg.Text:=StrPas(Addr(fpini));
> +           Cfg.Text:=StrPas(Addr(fpini[0][1]));
>        end;
>  
>        AddToList(List,'TEMPLATEFILE','builtin');
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list