浏览代码

--- Merging r31191 into '.':
A tests/webtbs/tw28475.pp
U compiler/ncnv.pas
--- Merging r31193 into '.':
U compiler/optcse.pas
A tests/webtbs/tw27210.pp
--- Merging r31263 into '.':
U compiler/options.pas
--- Merging r31335 into '.':
U compiler/dbgdwarf.pas
--- Merging r31466 into '.':
U compiler/arm/narmset.pas
--- Merging r31488 into '.':
U rtl/inc/astrings.inc
--- Merging r31572 into '.':
U compiler/arm/aasmcpu.pas
--- Merging r31608 into '.':
U compiler/x86/nx86cal.pas
--- Merging r31680 into '.':
U packages/chm/src/chmcmd.lpr
--- Merging r31851 into '.':
U rtl/jvm/math.inc
--- Merging r31956 into '.':
U tests/tbs/tb0320.pp
--- Merging r31976 into '.':
U rtl/linux/x86_64/cprt0.as
--- Merging r31980 into '.':
U compiler/systems/t_linux.pas
--- Merging r32043 into '.':
U compiler/cclasses.pas
--- Merging r32066 into '.':
G rtl/inc/astrings.inc
A tests/webtbs/tw28850.pp
--- Merging r32168 into '.':
U rtl/unix/cthreads.pp
--- Merging r32244 into '.':
U packages/fpmkunit/src/fpmkunit.pp
--- Merging r32259 into '.':
U compiler/x86/agx86int.pas
--- Merging r32338 into '.':
G compiler/ncnv.pas
--- Merging r32342 into '.':
G compiler/ncnv.pas
--- Merging r32368 into '.':
A tests/webtbs/tw29040.pp
U compiler/x86/rax86int.pas
--- Merging r32399 into '.':
U packages/fcl-res/src/machodefaulttarget.inc
--- Merging r32410 into '.':
U compiler/ncgset.pas
--- Merging r32454 into '.':
U compiler/jvm/pjvm.pas
U tests/test/jvm/testall.bat
A tests/test/jvm/tprocvaranon.pp
U tests/test/jvm/testall.sh
--- Merging r32517 into '.':
U compiler/nutils.pas
U compiler/pexpr.pas
A tests/webtbs/tw29030.pp
--- Merging r32527 into '.':
U rtl/linux/powerpc64/gprt0.as
U rtl/linux/powerpc64/cprt0.as
--- Merging r32528 into '.':
U rtl/linux/powerpc64/prt0.as
--- Merging r32549 into '.':
U compiler/jvm/njvmcon.pas
U compiler/jvm/njvmcnv.pascd ..
--- Merging r32584 into '.':
U compiler/utils/ppuutils/ppudump.pp
--- Merging r32599 into '.':
U compiler/paramgr.pas

git-svn-id: branches/fixes_3_0@32671 -

Jonas Maebe 9 年之前
父节点
当前提交
c7b40a6436

+ 6 - 0
.gitattributes

@@ -11079,6 +11079,7 @@ tests/test/jvm/tnestproc.pp svneol=native#text/plain
 tests/test/jvm/topovl.pp svneol=native#text/plain
 tests/test/jvm/topovl.pp svneol=native#text/plain
 tests/test/jvm/toverload.pp svneol=native#text/plain
 tests/test/jvm/toverload.pp svneol=native#text/plain
 tests/test/jvm/toverload2.pp svneol=native#text/plain
 tests/test/jvm/toverload2.pp svneol=native#text/plain
+tests/test/jvm/tprocvaranon.pp svneol=native#text/plain
 tests/test/jvm/tprop.pp svneol=native#text/plain
 tests/test/jvm/tprop.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tprop3.pp svneol=native#text/plain
 tests/test/jvm/tprop3.pp svneol=native#text/plain
@@ -14238,6 +14239,7 @@ tests/webtbs/tw27153.pp svneol=native#text/pascal
 tests/webtbs/tw27173.pp svneol=native#text/pascal
 tests/webtbs/tw27173.pp svneol=native#text/pascal
 tests/webtbs/tw27185.pp svneol=native#text/pascal
 tests/webtbs/tw27185.pp svneol=native#text/pascal
 tests/webtbs/tw2721.pp svneol=native#text/plain
 tests/webtbs/tw2721.pp svneol=native#text/plain
+tests/webtbs/tw27210.pp svneol=native#text/plain
 tests/webtbs/tw2723.pp svneol=native#text/plain
 tests/webtbs/tw2723.pp svneol=native#text/plain
 tests/webtbs/tw2725.pp svneol=native#text/plain
 tests/webtbs/tw2725.pp svneol=native#text/plain
 tests/webtbs/tw27256.pp svneol=native#text/pascal
 tests/webtbs/tw27256.pp svneol=native#text/pascal
@@ -14287,6 +14289,7 @@ tests/webtbs/tw2830.pp svneol=native#text/plain
 tests/webtbs/tw2832.pp svneol=native#text/plain
 tests/webtbs/tw2832.pp svneol=native#text/plain
 tests/webtbs/tw2834.pp svneol=native#text/plain
 tests/webtbs/tw2834.pp svneol=native#text/plain
 tests/webtbs/tw2841.pp svneol=native#text/plain
 tests/webtbs/tw2841.pp svneol=native#text/plain
+tests/webtbs/tw28475.pp svneol=native#text/plain
 tests/webtbs/tw2853.pp svneol=native#text/plain
 tests/webtbs/tw2853.pp svneol=native#text/plain
 tests/webtbs/tw28530.pp svneol=native#text/pascal
 tests/webtbs/tw28530.pp svneol=native#text/pascal
 tests/webtbs/tw2853a.pp svneol=native#text/plain
 tests/webtbs/tw2853a.pp svneol=native#text/plain
@@ -14305,13 +14308,16 @@ tests/webtbs/tw28718d.pp svneol=native#text/plain
 tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain
+tests/webtbs/tw28850.pp svneol=native#text/plain
 tests/webtbs/tw2886.pp svneol=native#text/plain
 tests/webtbs/tw2886.pp svneol=native#text/plain
 tests/webtbs/tw2891.pp svneol=native#text/plain
 tests/webtbs/tw2891.pp svneol=native#text/plain
 tests/webtbs/tw2892.pp svneol=native#text/plain
 tests/webtbs/tw2892.pp svneol=native#text/plain
 tests/webtbs/tw28934.pp svneol=native#text/plain
 tests/webtbs/tw28934.pp svneol=native#text/plain
 tests/webtbs/tw2897.pp svneol=native#text/plain
 tests/webtbs/tw2897.pp svneol=native#text/plain
 tests/webtbs/tw2899.pp svneol=native#text/plain
 tests/webtbs/tw2899.pp svneol=native#text/plain
+tests/webtbs/tw29030.pp svneol=native#text/plain
 tests/webtbs/tw2904.pp svneol=native#text/plain
 tests/webtbs/tw2904.pp svneol=native#text/plain
+tests/webtbs/tw29040.pp svneol=native#text/plain
 tests/webtbs/tw2908.pp svneol=native#text/plain
 tests/webtbs/tw2908.pp svneol=native#text/plain
 tests/webtbs/tw2911.pp svneol=native#text/plain
 tests/webtbs/tw2911.pp svneol=native#text/plain
 tests/webtbs/tw2912.pp svneol=native#text/plain
 tests/webtbs/tw2912.pp svneol=native#text/plain

+ 3 - 1
compiler/arm/aasmcpu.pas

@@ -894,7 +894,9 @@ implementation
                (tai(hp).typ=ait_instruction) and
                (tai(hp).typ=ait_instruction) and
                ((taicpu(hp).opcode=A_FLDS) or
                ((taicpu(hp).opcode=A_FLDS) or
                 (taicpu(hp).opcode=A_FLDD) or
                 (taicpu(hp).opcode=A_FLDD) or
-                (taicpu(hp).opcode=A_VLDR)) then
+                (taicpu(hp).opcode=A_VLDR) or
+                (taicpu(hp).opcode=A_LDF) or
+                (taicpu(hp).opcode=A_STF)) then
               limit:=254;
               limit:=254;
         end;
         end;
 
 

+ 11 - 2
compiler/arm/narmset.pas

@@ -51,7 +51,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      verbose,globals,constexp,defutil,
+      verbose,globals,constexp,defutil,systems,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       cpubase,cpuinfo,
       cpubase,cpuinfo,
       cgutils,cgobj,ncgutil,
       cgutils,cgobj,ncgutil,
@@ -72,7 +72,8 @@ implementation
         if not(assigned(result)) then
         if not(assigned(result)) then
           begin
           begin
             if not(checkgenjumps(setparts,numparts,use_small)) and
             if not(checkgenjumps(setparts,numparts,use_small)) and
-              use_small then
+              use_small and
+              (target_info.endian=endian_little) then
               expectloc:=LOC_FLAGS;
               expectloc:=LOC_FLAGS;
           end;
           end;
       end;
       end;
@@ -82,6 +83,14 @@ implementation
         so : tshifterop;
         so : tshifterop;
         hregister : tregister;
         hregister : tregister;
       begin
       begin
+        { the code below needs changes for big endian targets (they start
+          counting from the most significant bit)
+        }
+        if target_info.endian=endian_big then
+          begin
+            inherited;
+            exit;
+          end;
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=F_NE;
         location.resflags:=F_NE;
         if (left.location.loc=LOC_CONSTANT) and not(GenerateThumbCode) then
         if (left.location.loc=LOC_CONSTANT) and not(GenerateThumbCode) then

+ 1 - 1
compiler/cclasses.pas

@@ -2924,7 +2924,7 @@ end;
         i: Integer;
         i: Integer;
         e, n: PHashSetItem;
         e, n: PHashSetItem;
       begin
       begin
-        p := AllocMem(NewCapacity * SizeOfItem);
+        p := AllocMem(NewCapacity * SizeOf(PHashSetItem));
         for i := 0 to FBucketCount-1 do
         for i := 0 to FBucketCount-1 do
           begin
           begin
             e := FBucket[i];
             e := FBucket[i];

+ 6 - 0
compiler/dbgdwarf.pas

@@ -3347,6 +3347,12 @@ implementation
       begin
       begin
         { this function will always terminate the lineinfo block }
         { this function will always terminate the lineinfo block }
         generated_lineinfo := true;
         generated_lineinfo := true;
+        { if this unit only contains code without debug info (implicit init
+          or final etc), make sure the file table contains at least one entry
+          (the main source of the unit), because normally this table gets
+          populated via calls to get_file_index and that won't happen in this
+          case }
+        get_file_index(current_module.sourcefiles.get_file(1));
         FillChar(lastfileinfo,sizeof(lastfileinfo),0);
         FillChar(lastfileinfo,sizeof(lastfileinfo),0);
         currfuncname:=nil;
         currfuncname:=nil;
         currsectype:=sec_code;
         currsectype:=sec_code;

+ 1 - 1
compiler/jvm/njvmcnv.pas

@@ -476,7 +476,7 @@ implementation
                      { get the class representing the primitive type }
                      { get the class representing the primitive type }
                      fvs:=search_struct_member(tobjectdef(corrclass),'FTYPE');
                      fvs:=search_struct_member(tobjectdef(corrclass),'FTYPE');
                      newpara:=nil;
                      newpara:=nil;
-                     if not handle_staticfield_access(fvs,false,newpara) then
+                     if not handle_staticfield_access(fvs,newpara) then
                        internalerror(2011072417);
                        internalerror(2011072417);
                    end
                    end
                  else
                  else

+ 1 - 1
compiler/jvm/njvmcon.pas

@@ -125,7 +125,7 @@ implementation
 
 
         { c) create loadnode of the field }
         { c) create loadnode of the field }
         result:=nil;
         result:=nil;
-        if not handle_staticfield_access(classfield,false,result) then
+        if not handle_staticfield_access(classfield,result) then
           internalerror(2011062606);
           internalerror(2011062606);
       end;
       end;
 
 

+ 4 - 1
compiler/jvm/pjvm.pas

@@ -475,7 +475,10 @@ implementation
           FpcBaseNestedProcVarType, pass nestedfpstruct to constructor and
           FpcBaseNestedProcVarType, pass nestedfpstruct to constructor and
           copy it }
           copy it }
         if name='' then
         if name='' then
-          internalerror(2011071901);
+          begin
+            if is_nested_pd(tabstractprocdef(def)) then
+              internalerror(2011071901);
+          end;
 
 
         setup_for_new_class('jvm_pvar_class',sstate,islocal,oldsymtablestack);
         setup_for_new_class('jvm_pvar_class',sstate,islocal,oldsymtablestack);
 
 

+ 1 - 1
compiler/ncgset.pas

@@ -202,7 +202,7 @@ implementation
              left.resultdef, opdef, true);
              left.resultdef, opdef, true);
             register_maybe_adjust_setbase(current_asmdata.CurrAsmList, left.location,
             register_maybe_adjust_setbase(current_asmdata.CurrAsmList, left.location,
              setbase);
              setbase);
-            hlcg.a_bit_test_reg_loc_reg(current_asmdata.CurrAsmList, left.resultdef,
+            hlcg.a_bit_test_reg_loc_reg(current_asmdata.CurrAsmList, opdef,
               right.resultdef, resultdef, left.location.register, right.location,
               right.resultdef, resultdef, left.location.register, right.location,
                location.register);
                location.register);
           end;
           end;

+ 7 - 2
compiler/ncnv.pas

@@ -2137,7 +2137,8 @@ implementation
             cdoptions:=[cdo_allow_variant,cdo_warn_incompatible_univ];
             cdoptions:=[cdo_allow_variant,cdo_warn_incompatible_univ];
             { overloaded operators require calls, which is not possible inside
             { overloaded operators require calls, which is not possible inside
               a constant declaration }
               a constant declaration }
-            if block_type<>bt_const then
+            if (block_type<>bt_const) and
+               not(nf_internal in flags) then
               include(cdoptions,cdo_check_operator);
               include(cdoptions,cdo_check_operator);
             if nf_explicit in flags then
             if nf_explicit in flags then
               include(cdoptions,cdo_explicit);
               include(cdoptions,cdo_explicit);
@@ -2551,8 +2552,12 @@ implementation
             end;
             end;
           typeconvn:
           typeconvn:
             begin
             begin
-              n.resultdef:=todef;
               ttypeconvnode(n).totypedef:=todef;
               ttypeconvnode(n).totypedef:=todef;
+              { may change the type conversion, e.g. if the old conversion was
+                from 64 bit to a 64 bit, and now becomes 64 bit to 32 bit }
+              n.resultdef:=nil;
+              ttypeconvnode(n).convtype:=tc_none;
+              typecheckpass(n);
             end;
             end;
           else
           else
             inserttypeconv_internal(n,todef);
             inserttypeconv_internal(n,todef);

+ 3 - 6
compiler/nutils.pas

@@ -100,7 +100,7 @@ interface
 
 
     { checks whether sym is a static field and if so, translates the access
     { checks whether sym is a static field and if so, translates the access
       to the appropriate node tree }
       to the appropriate node tree }
-    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
+    function handle_staticfield_access(sym: tsym; var p1: tnode): boolean;
 
 
     { returns true if n is an array element access of a bitpacked array with
     { returns true if n is an array element access of a bitpacked array with
       elements of the which the vitsize mod 8 <> 0, or if is a field access
       elements of the which the vitsize mod 8 <> 0, or if is a field access
@@ -1042,7 +1042,7 @@ implementation
       end;
       end;
 
 
 
 
-    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
+    function handle_staticfield_access(sym: tsym; var p1: tnode): boolean;
 
 
       function handle_generic_staticfield_access:boolean;
       function handle_generic_staticfield_access:boolean;
         var
         var
@@ -1089,10 +1089,7 @@ implementation
             result:=true;
             result:=true;
             if handle_generic_staticfield_access then
             if handle_generic_staticfield_access then
               exit;
               exit;
-            if not nested then
-              static_name:=lower(sym.owner.name^)+'_'+sym.name
-            else
-             static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
+            static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
             if sym.owner.defowner.typ=objectdef then
             if sym.owner.defowner.typ=objectdef then
               searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable,[ssf_search_helper])
               searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable,[ssf_search_helper])
             else
             else

+ 10 - 3
compiler/optcse.pas

@@ -143,9 +143,16 @@ unit optcse;
         { don't add the tree below an untyped const parameter: there is
         { don't add the tree below an untyped const parameter: there is
           no information available that this kind of tree actually needs
           no information available that this kind of tree actually needs
           to be addresable, this could be improved }
           to be addresable, this could be improved }
-        if ((n.nodetype=callparan) and
-          (tcallparanode(n).left.resultdef.typ=formaldef) and
-          (tcallparanode(n).parasym.varspez=vs_const)) then
+        { the nodes below a type conversion node created for an absolute
+          reference cannot be handled separately, because the absolute reference
+          may have special requirements (no regability, must be in memory, ...)
+        }
+        if (((n.nodetype=callparan) and
+             (tcallparanode(n).left.resultdef.typ=formaldef) and
+             (tcallparanode(n).parasym.varspez=vs_const)) or
+            ((n.nodetype=typeconvn) and
+             (nf_absolute in n.flags))
+           ) then
           begin
           begin
             result:=fen_norecurse_false;
             result:=fen_norecurse_false;
             exit;
             exit;

+ 2 - 0
compiler/options.pas

@@ -2644,6 +2644,7 @@ begin
                if (s='WRITE') then
                if (s='WRITE') then
                 begin
                 begin
                   Delete(opts,1,1);
                   Delete(opts,1,1);
+                  DefaultReplacements(opts);
                   WriteLn(opts);
                   WriteLn(opts);
                   Option_read:=true;
                   Option_read:=true;
                 end
                 end
@@ -2651,6 +2652,7 @@ begin
                if (s='INCLUDE') then
                if (s='INCLUDE') then
                 begin
                 begin
                   Delete(opts,1,1);
                   Delete(opts,1,1);
+                  DefaultReplacements(opts);
                   Interpret_file(opts);
                   Interpret_file(opts);
                   Option_read:=true;
                   Option_read:=true;
                 end
                 end

+ 5 - 1
compiler/paramgr.pas

@@ -403,7 +403,11 @@ implementation
             newparaloc:=cgpara.add_location;
             newparaloc:=cgpara.add_location;
             newparaloc^.size:=paraloc^.size;
             newparaloc^.size:=paraloc^.size;
             newparaloc^.def:=paraloc^.def;
             newparaloc^.def:=paraloc^.def;
-            newparaloc^.shiftval:=paraloc^.shiftval;
+            { shiftval overlaps with part of the reference, so it may be
+              different from 0 and if wr then force the newparaloc to a register
+              in the optimization below, shiftval will remain <> 0 }
+            if not(paraloc^.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
+              newparaloc^.shiftval:=paraloc^.shiftval;
             { $warning maybe release this optimization for all targets?  }
             { $warning maybe release this optimization for all targets?  }
             { released for all CPUs:
             { released for all CPUs:
               i386 isn't affected anyways because it uses the stack to push parameters
               i386 isn't affected anyways because it uses the stack to push parameters

+ 3 - 3
compiler/pexpr.pas

@@ -1164,7 +1164,7 @@ implementation
                      fieldvarsym :
                      fieldvarsym :
                        begin
                        begin
                          { generate access code }
                          { generate access code }
-                         if not handle_staticfield_access(sym,false,p1) then
+                         if not handle_staticfield_access(sym,p1) then
                            propaccesslist_to_node(p1,st,propaccesslist);
                            propaccesslist_to_node(p1,st,propaccesslist);
                          include(p1.flags,nf_isproperty);
                          include(p1.flags,nf_isproperty);
                          consume(_ASSIGNMENT);
                          consume(_ASSIGNMENT);
@@ -1194,7 +1194,7 @@ implementation
                      fieldvarsym :
                      fieldvarsym :
                        begin
                        begin
                          { generate access code }
                          { generate access code }
-                         if not handle_staticfield_access(sym,false,p1) then
+                         if not handle_staticfield_access(sym,p1) then
                            propaccesslist_to_node(p1,st,propaccesslist);
                            propaccesslist_to_node(p1,st,propaccesslist);
                          include(p1.flags,nf_isproperty);
                          include(p1.flags,nf_isproperty);
                          { catch expressions like "(propx):=1;" }
                          { catch expressions like "(propx):=1;" }
@@ -1297,7 +1297,7 @@ implementation
                    end;
                    end;
                  fieldvarsym:
                  fieldvarsym:
                    begin
                    begin
-                      if not handle_staticfield_access(sym,true,p1) then
+                      if not handle_staticfield_access(sym,p1) then
                         begin
                         begin
                           if isclassref then
                           if isclassref then
                             if assigned(p1) and
                             if assigned(p1) and

+ 3 - 1
compiler/systems/t_linux.pas

@@ -146,9 +146,11 @@ begin
 {$endif}
 {$endif}
 {$endif arm}
 {$endif arm}
 {$ifdef x86_64}
 {$ifdef x86_64}
-  if not Dontlinkstdlibpath Then
     LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/x86_64-linux-gnu',true);
     LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/x86_64-linux-gnu',true);
 {$endif x86_64}
 {$endif x86_64}
+{$ifdef i386}
+    LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/i386-linux-gnu',true);
+{$endif i386}
 end;
 end;
 
 
 {$ifdef m68k}
 {$ifdef m68k}

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -782,7 +782,8 @@ begin
   derefdatalen:=ppufile.entrysize;
   derefdatalen:=ppufile.entrysize;
   if derefdatalen=0 then
   if derefdatalen=0 then
     begin
     begin
-      WriteError('!! Error: derefdatalen=0');
+      Writeln(['No Derefdata length=0']);
+      derefdata:=nil;
       exit;
       exit;
     end;
     end;
   Writeln(['Derefdata length: ',derefdatalen]);
   Writeln(['Derefdata length: ',derefdatalen]);

+ 5 - 0
compiler/x86/agx86int.pas

@@ -741,6 +741,11 @@ implementation
                   repeat
                   repeat
                     hp:=tai(hp.next);
                     hp:=tai(hp.next);
                   until (hp=nil) or (hp.typ=ait_instruction);
                   until (hp=nil) or (hp.typ=ait_instruction);
+
+                  { next instruction ... }
+                  fixed_opcode:=taicpu(hp).FixNonCommutativeOpcodes;
+                  taicpu(hp).SetOperandOrder(op_intel);
+
                   { this is theorically impossible... }
                   { this is theorically impossible... }
                   if hp=nil then
                   if hp=nil then
                    begin
                    begin

+ 4 - 2
compiler/x86/nx86cal.pas

@@ -48,7 +48,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      cgobj,
+      globtype,cgobj,
       cgbase,cpubase,cgx86,cga,aasmdata,aasmcpu;
       cgbase,cpubase,cgx86,cga,aasmdata,aasmcpu;
 
 
 
 
@@ -87,7 +87,9 @@ implementation
   function tx86callnode.can_call_ref(var ref: treference): boolean;
   function tx86callnode.can_call_ref(var ref: treference): boolean;
     begin
     begin
       tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,ref);
       tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,ref);
-      result:=true;
+      { do not use a ref. for calling conventions which allocate all registers, the reg. allocator cannot handle this, see
+        also issue #28639, I were not able to create a simple example though to cause the resulting endless spilling }
+      result:=not(procdefinition.proccalloption in [pocall_far16,pocall_pascal,pocall_oldfpccall]);
     end;
     end;
 
 
 
 

+ 3 - 0
compiler/x86/rax86int.pas

@@ -228,6 +228,9 @@ Unit Rax86int;
       begin
       begin
         is_register:=false;
         is_register:=false;
         actasmregister:=masm_regnum_search(lower(s));
         actasmregister:=masm_regnum_search(lower(s));
+        { don't acceps "flags" as register name in an instruction }
+        if actasmregister=NR_FLAGS then
+          actasmregister:=NR_NO;
         if (actasmregister=NR_NO) and
         if (actasmregister=NR_NO) and
            (current_procinfo.procdef.proccalloption=pocall_register) and
            (current_procinfo.procdef.proccalloption=pocall_register) and
            (po_assembler in current_procinfo.procdef.procoptions) then
            (po_assembler in current_procinfo.procdef.procoptions) then

+ 1 - 1
packages/chm/src/chmcmd.lpr

@@ -155,7 +155,7 @@ begin
          end;
          end;
        end;
        end;
     end;
     end;
-  OutStream := TFileStream.Create(Project.OutputFileName, fmCreate, fmOpenWrite);
+  OutStream := TFileStream.Create(Project.OutputFileName, fmCreate);
   Project.WriteChm(OutStream);
   Project.WriteChm(OutStream);
   if Project.ScanHtmlContents then
   if Project.ScanHtmlContents then
     Project.ShowUndefinedAnchors;
     Project.ShowUndefinedAnchors;

+ 3 - 0
packages/fcl-res/src/machodefaulttarget.inc

@@ -26,6 +26,9 @@
   {$IFDEF CPUX86_64}
   {$IFDEF CPUX86_64}
   fMachineType:=mmtx86_64;
   fMachineType:=mmtx86_64;
   {$ENDIF}
   {$ENDIF}
+  {$IFDEF CPUARM}
+  fMachineType:=mmtarm;
+  {$ENDIF}
 
 
   fBits:=MACH_ERRBIT;
   fBits:=MACH_ERRBIT;
   {$IFDEF CPU32}
   {$IFDEF CPU32}

+ 1 - 1
packages/fpmkunit/src/fpmkunit.pp

@@ -2555,7 +2555,7 @@ var
 begin
 begin
   S:=TProcess.Create(Nil);
   S:=TProcess.Create(Nil);
   S.Commandline:=ACompiler+' '+AOptions;
   S.Commandline:=ACompiler+' '+AOptions;
-  S.Options:=[poUsePipes];
+  S.Options:=[poUsePipes,poWaitOnExit];
   S.execute;
   S.execute;
   Count:=s.output.read(buf,BufSize);
   Count:=s.output.read(buf,BufSize);
   if (count=0) and ReadStdErr then
   if (count=0) and ReadStdErr then

+ 11 - 2
rtl/inc/astrings.inc

@@ -1383,7 +1383,10 @@ begin
    index := LS+1;
    index := LS+1;
   Dec(Index);
   Dec(Index);
   SetLength(Temp,Length(Source)+LS);
   SetLength(Temp,Length(Source)+LS);
-  cp:=TranslatePlaceholderCP(StringCodePage(S));
+  if length(S)<>0 then
+    cp:=TranslatePlaceholderCP(StringCodePage(S))
+  else
+    cp:=TranslatePlaceholderCP(StringCodePage(Source));
   SetCodePage(Temp,cp,false);
   SetCodePage(Temp,cp,false);
   If Index>0 then
   If Index>0 then
     fpc_pchar_ansistr_intern_charmove(pchar(S),0,Temp,0,Index);
     fpc_pchar_ansistr_intern_charmove(pchar(S),0,Temp,0,Index);
@@ -1526,14 +1529,20 @@ procedure InternalSetCodePage(var s : RawByteString; CodePage : TSystemCodePage;
   extra exception frames }
   extra exception frames }
 procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
 procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
   var
   var
+    OrgCodePage,
     TranslatedCodePage,
     TranslatedCodePage,
     TranslatedCurrentCodePage: TSystemCodePage;
     TranslatedCurrentCodePage: TSystemCodePage;
   begin
   begin
     if (S='') then
     if (S='') then
       exit;
       exit;
+    { if the codepage are identical, we don't have to do anything (even if the
+      string has multiple references) }
+    OrgCodePage:=PAnsiRec(pointer(S)-AnsiFirstOff)^.CodePage;
+    if OrgCodePage=CodePage then
+      exit;
     { if we're just replacing a placeholder code page with its actual value or
     { if we're just replacing a placeholder code page with its actual value or
       vice versa, we don't have to perform any conversion }
       vice versa, we don't have to perform any conversion }
-    TranslatedCurrentCodePage:=TranslatePlaceholderCP(PAnsiRec(pointer(S)-AnsiFirstOff)^.CodePage);
+    TranslatedCurrentCodePage:=TranslatePlaceholderCP(OrgCodePage);
     TranslatedCodePage:=TranslatePlaceholderCP(CodePage);
     TranslatedCodePage:=TranslatePlaceholderCP(CodePage);
     Convert:=Convert and
     Convert:=Convert and
       (TranslatedCurrentCodePage<>TranslatedCodePage);
       (TranslatedCurrentCodePage<>TranslatedCodePage);

+ 4 - 0
rtl/jvm/math.inc

@@ -63,6 +63,8 @@ function fpc_sin_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inl
 function fpc_sqr_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 function fpc_sqr_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
   begin
   begin
     HandleError(219);
     HandleError(219);
+    { avoid warning }
+    result:=0;
   end;
   end;
 
 
 
 
@@ -77,6 +79,8 @@ function fpc_sqrt_real(d : ValReal) : ValReal;compilerproc;
 function fpc_trunc_real(d : ValReal) : int64;compilerproc;
 function fpc_trunc_real(d : ValReal) : int64;compilerproc;
   begin
   begin
     HandleError(219);
     HandleError(219);
+    { avoid warning }
+    result:=0;
   end;
   end;
 
 
 
 

+ 1 - 1
rtl/linux/powerpc64/cprt0.as

@@ -373,7 +373,7 @@ FUNCTION_PROLOG _start
     /* PPC64 ABI uses R13 for thread local, so we leave it alone */
     /* PPC64 ABI uses R13 for thread local, so we leave it alone */
     LOAD_64BIT_VAL 8, start_addresses
     LOAD_64BIT_VAL 8, start_addresses
 
 
-    b   .__libc_start_main
+    bl      __libc_start_main
     nop                      /* a NOP for the linker */
     nop                      /* a NOP for the linker */
 
 
 /*
 /*

+ 5 - 5
rtl/linux/powerpc64/gprt0.as

@@ -373,7 +373,7 @@ FUNCTION_PROLOG _start
     /* PPC64 ABI uses R13 for thread local, so we leave it alone */
     /* PPC64 ABI uses R13 for thread local, so we leave it alone */
     LOAD_64BIT_VAL 8, start_addresses
     LOAD_64BIT_VAL 8, start_addresses
 
 
-    b   .__libc_start_main
+    b       __libc_start_main
     nop                      /* a NOP for the linker */
     nop                      /* a NOP for the linker */
 
 
 /*
 /*
@@ -404,17 +404,17 @@ FUNCTION_PROLOG main_stub
     LOAD_64BIT_VAL 3, _start
     LOAD_64BIT_VAL 3, _start
     ld      3, 0(3)
     ld      3, 0(3)
     LOAD_64BIT_VAL 4, etext
     LOAD_64BIT_VAL 4, etext
-    bl  .__monstartup
+    bl      __monstartup
     nop
     nop
 
 
     LOAD_64BIT_VAL 3, _mcleanup
     LOAD_64BIT_VAL 3, _mcleanup
-    bl .atexit
+    bl      atexit
     nop
     nop
 
 
-    bl  .PASCALMAIN
+    bl      PASCALMAIN
     nop
     nop
 
 
-    b   ._haltproc
+    b       ._haltproc
 
 
 FUNCTION_PROLOG _haltproc
 FUNCTION_PROLOG _haltproc
     LOAD_64BIT_VAL 8, ___fpc_ret
     LOAD_64BIT_VAL 8, ___fpc_ret

+ 20 - 4
rtl/linux/powerpc64/prt0.as

@@ -324,17 +324,33 @@ _restvr_31: addi r12,r0,-16
  * Main program entry point for dynamic executables.
  * Main program entry point for dynamic executables.
  *
  *
  * r7 contains the function pointer that needs to be registered for calling at exit.
  * r7 contains the function pointer that needs to be registered for calling at exit.
+ * r3/r4/r5 contain argc/argv/envp
  */
  */
 FUNCTION_PROLOG _dynamic_start
 FUNCTION_PROLOG _dynamic_start
   LOAD_64BIT_VAL 11, __dl_fini
   LOAD_64BIT_VAL 11, __dl_fini
   std      7,0(11)
   std      7,0(11)
-  LOAD_64BIT_VAL 11, _start
-  /* do not bother loading the actual function address of _start. We can directly jump to it */
-  /* set up GOT pointer from original start function */
+  LOAD_64BIT_VAL 11, PASCALMAIN
+  /* set up GOT pointer from PASCALMAIN */
   ld       2,8(11)
   ld       2,8(11)
   /* and environment pointer */
   /* and environment pointer */
   ld      11,16(11)
   ld      11,16(11)
-  b       _start
+  /* store argument count */
+  LOAD_64BIT_VAL 10,operatingsystem_parameter_argc
+  stw     3,0(10)
+  /* store argument address */
+  LOAD_64BIT_VAL 10,operatingsystem_parameter_argv
+  std     4,0(10)
+  /* store environment pointer */
+  std     5,0(10)
+
+  LOAD_64BIT_VAL 8,__stkptr
+  std     1,0(8)
+
+  bl      PASCALMAIN
+  nop
+
+  /* we should not reach here. Crash horribly */
+  trap
 .long 0
 .long 0
 .byte 0, 12, 64, 0, 0, 0, 0, 0
 .byte 0, 12, 64, 0, 0, 0, 0, 0
 
 

+ 2 - 14
rtl/linux/x86_64/cprt0.as

@@ -63,8 +63,8 @@ _start:
 	pushq %rsp
 	pushq %rsp
 
 
 	/* Pass address of our own entry points to .fini and .init.  */
 	/* Pass address of our own entry points to .fini and .init.  */
-	movq _init_dummy@GOTPCREL(%rip), %rcx
-	movq _fini_dummy@GOTPCREL(%rip), %r8
+	movq __libc_csu_init@GOTPCREL(%rip), %rcx
+	movq __libc_csu_fini@GOTPCREL(%rip), %r8
 
 
 	movq main_stub@GOTPCREL(%rip), %rdi
 	movq main_stub@GOTPCREL(%rip), %rdi
 
 
@@ -116,18 +116,6 @@ _haltproc:
 	ret
 	ret
 	.size   _haltproc,.-_haltproc
 	.size   _haltproc,.-_haltproc
 
 
-	.globl _init_dummy
-        .type   _init_dummy, @function
-_init_dummy:
-        ret
-	.size   _init_dummy,.-_init_dummy
-
-	.globl  _fini_dummy
-        .type   _fini_dummy, @function
-_fini_dummy:
-        ret
-	.size   _fini_dummy,.-_fini_dummy
-
 /* Define a symbol for the first piece of initialized data.  */
 /* Define a symbol for the first piece of initialized data.  */
 	.data
 	.data
 	.globl __data_start
 	.globl __data_start

+ 14 - 2
rtl/unix/cthreads.pp

@@ -172,11 +172,19 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
         s := 'finishing externally started thread'#10;
         s := 'finishing externally started thread'#10;
         fpwrite(0,s[1],length(s));
         fpwrite(0,s[1],length(s));
 {$endif DEBUG_MT}
 {$endif DEBUG_MT}
+        { Restore tlskey value as it may already have been set to null,
+          in which case
+            a) DoneThread can't release the memory
+            b) accesses to threadvars from DoneThread or anything it
+               calls would allocate new threadvar memory
+        }
+        pthread_setspecific(tlskey,p);
         { clean up }
         { clean up }
         DoneThread;
         DoneThread;
         { the pthread routine that calls us is supposed to do this, but doesn't
         { the pthread routine that calls us is supposed to do this, but doesn't
           at least on Mac OS X 10.6 }
           at least on Mac OS X 10.6 }
         pthread_setspecific(CleanupKey,nil);
         pthread_setspecific(CleanupKey,nil);
+        pthread_setspecific(tlskey,nil);
       end;
       end;
 
 
 
 
@@ -188,8 +196,12 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
         { we cannot know the stack size of the current thread, so pretend it
         { we cannot know the stack size of the current thread, so pretend it
           is really large to prevent spurious stack overflow errors }
           is really large to prevent spurious stack overflow errors }
         InitThread(1000000000);
         InitThread(1000000000);
-        { instruct the pthreads system to clean up this thread when it exits }
-        pthread_setspecific(CleanupKey,pointer(1));
+        { instruct the pthreads system to clean up this thread when it exits.
+          Use current tlskey as value so that if tlskey is cleared before
+          CleanupKey is called, we still know its value (the order in which
+          pthread tls data is zeroed by pthreads is undefined, and under some
+          systems the tlskey is cleared first) }
+        pthread_setspecific(CleanupKey,pthread_getspecific(tlskey));
       end;
       end;
 
 
 
 

+ 2 - 1
tests/tbs/tb0320.pp

@@ -8,6 +8,7 @@ const
 type
 type
   trec=record
   trec=record
     a,b : longint;
     a,b : longint;
+    c: longint;
   end;
   end;
 
 
 var
 var
@@ -27,5 +28,5 @@ begin
     mov fs:[0468+trec.b],eax
     mov fs:[0468+trec.b],eax
     mov fs:[046ch],eax
     mov fs:[046ch],eax
 {$endif}
 {$endif}
-  end;
+  end ['eax','esi'];
 end.
 end.

+ 4 - 0
tests/test/jvm/testall.bat

@@ -320,3 +320,7 @@ ppcjvm -O2 -g -B  -CTinitlocals tformalclass
 if %errorlevel% neq 0 exit /b %errorlevel%
 if %errorlevel% neq 0 exit /b %errorlevel%
 java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tformalclass
 java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tformalclass
 if %errorlevel% neq 0 exit /b %errorlevel%
 if %errorlevel% neq 0 exit /b %errorlevel%
+ppcjvm -O2 -g -B  -CTinitlocals tprocvaranon
+if %errorlevel% neq 0 exit /b %errorlevel%
+java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tprocvaranon
+if %errorlevel% neq 0 exit /b %errorlevel%

+ 2 - 0
tests/test/jvm/testall.sh

@@ -187,3 +187,5 @@ java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tsetstring
 $PPC -O2 -g -B -Sa tnestcallpass1
 $PPC -O2 -g -B -Sa tnestcallpass1
 $PPC -O2 -g -B -Sa tformalclass
 $PPC -O2 -g -B -Sa tformalclass
 java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tformalclass
 java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tformalclass
+$PPC -O2 -g -B -Sa tprocvaranon
+java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tprocvaranon

+ 20 - 0
tests/test/jvm/tprocvaranon.pp

@@ -0,0 +1,20 @@
+program tprocvaranon;
+
+type
+  tprocvaranonrec = record
+    p: function: longint;
+  end;
+
+function test: longint;
+begin
+  test:=123;
+end;
+
+var
+  r: tprocvaranonrec;
+begin
+ r.p:=@test;
+ if r.p()<>123 then
+   halt(1);
+end.
+    

+ 31 - 0
tests/webtbs/tw27210.pp

@@ -0,0 +1,31 @@
+{$mode delphi}
+
+program TestAbsolute; {$apptype console}
+
+function IsInt16 (L : longint) : boolean;
+var W : smallint absolute L;
+begin
+  Result := longint (W) = L;
+end;
+
+function IsInt32 (Q : int64) : boolean;
+var L : longint absolute Q;
+begin
+  Result := int64 (L) = Q;
+end;
+
+const VL1 : longint = -1;
+      VL2 : longint = $12345678;
+      VQ1 : int64   = -1;
+      VQ2 : int64   = $123456781234;
+
+begin
+  if not IsInt16 (VL1) then
+    halt(1);
+  if IsInt16 (VL2) then
+    halt(2);
+  if not IsInt32 (VQ1) then
+    halt(3);
+  if IsInt32 (VQ2) then
+    halt(4);
+end.

+ 24 - 0
tests/webtbs/tw28475.pp

@@ -0,0 +1,24 @@
+{ %opt=-g-t }
+
+program trashtest;
+
+{$MODE OBJFPC}
+
+type
+        TTestRec = record
+                Field1 : Int64;
+        end;
+
+operator := (i: TTestRec) fR: Int64;
+begin
+        fR := i.Field1;
+end;
+
+function TestFunc:TTestRec;
+begin //error reported here
+        TestFunc.Field1 := 1;
+end;
+
+begin
+        WriteLn(TestFunc.Field1);
+end.

+ 20 - 0
tests/webtbs/tw28850.pp

@@ -0,0 +1,20 @@
+var
+  s1, s2: ansistring;
+begin
+  s1 := 'abc';
+  s2:='';
+  { ensure the codepage of s1 is different from defaultsystemcodepage }
+  if defaultsystemcodepage=866 then
+    setcodepage(rawbytestring(s1),1251,false)
+  else
+    setcodepage(rawbytestring(s1),866,false); 
+  { if the destination is empty, insert must create a new string
+    with the same code page as the source }
+  Insert(s1, s2, 1);
+  if StringRefCount(s1)<>1 then
+    halt(1);
+  if StringRefCount(s2)<>1 then
+    halt(2);
+  if stringcodepage(s2)<>stringcodepage(s1) then
+    halt(3);
+end.

+ 19 - 0
tests/webtbs/tw29030.pp

@@ -0,0 +1,19 @@
+program fpc_nestedtype_ice;
+
+{$mode delphiunicode}
+
+Type
+ TRec = Record
+  Type
+   NestedType = Record
+    Class Var
+     FVar : Integer;
+    Class Property Variable : Integer Read FVar Write FVar;
+   End;
+  End;
+
+Begin
+ TRec.NestedType.Variable := 1;
+ if TRec.NestedType.Variable<>1 then
+   halt(1);
+End.

+ 37 - 0
tests/webtbs/tw29040.pp

@@ -0,0 +1,37 @@
+{ %cpu=i386 }
+{ %norun }
+
+program asm_test004;
+{$APPTYPE CONSOLE}
+{$OPTIMIZATION SIZE}
+{$OPTIMIZATION STACKFRAME}
+{$OPTIMIZATION REGVAR}
+{$CODEALIGN VARMIN=1}
+{$CODEALIGN VARMAX=1}
+{$CODEALIGN CONSTMIN=1}
+{$CODEALIGN CONSTMAX=1}
+{$mode delphi}
+{$asmmode intel}
+
+
+
+const
+wmoven = 1;
+            //  eax edx ecx  stack
+procedure test1(a , b , c,   flags :longint); register; //__ pbby in ver 3.0.0 the "flags" is reserved word _   with ver 2.6.4 no compilation error
+var
+f       :boolean;
+asm
+   mov a,0
+   mov b,0
+   mov c,0
+   test [flags] , wmoven
+   setnz f
+end;
+
+var
+i       :cardinal;
+
+begin
+ test1(i,i,i,i);
+end.