Kaynağa Gözat

Merged revisions 11266,11271,11278,11280-11282,11286-11288,11292-11294,11297,11299-11300,11302,11304-11311,11313,11315-11316,11318-11319,11324-11326,11328-11333,11335-11336,11339-11340,11346-11347,11349,11362,11367,11369,11371-11376,11392-11396,11401,11411-11414,11420,11422,11427-11428,11465,11469-11470,11474 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r11266 | florian | 2008-06-23 20:50:51 +0200 (Mon, 23 Jun 2008) | 1 line

* avoid ie 99080501 when overloading procedures with open arrays of widechar, resolves #11543
........
r11367 | florian | 2008-07-11 21:03:16 +0200 (Fri, 11 Jul 2008) | 1 line

* typos fixed
........
r11376 | florian | 2008-07-13 11:10:50 +0200 (Sun, 13 Jul 2008) | 1 line

* support ABSOLUTE32 in the COFF writer on x86-64, resolves #10641
........
r11392 | florian | 2008-07-17 21:49:38 +0200 (Thu, 17 Jul 2008) | 1 line

* allow goto inside finally blocks
........
r11474 | florian | 2008-07-28 17:51:58 +0200 (Mon, 28 Jul 2008) | 1 line

* avoid shifter constant overflow on arm when optimizing two shifter operations into one
........

git-svn-id: branches/fixes_2_2@12070 -

florian 17 yıl önce
ebeveyn
işleme
a0f70bc854

+ 5 - 0
.gitattributes

@@ -6245,6 +6245,7 @@ tests/tbf/tb0204.pp svneol=native#text/plain
 tests/tbf/tb0204a.pp svneol=native#text/plain
 tests/tbf/tb0205.pp svneol=native#text/plain
 tests/tbf/tb0208.pp svneol=native#text/plain
+tests/tbf/tb0209.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
@@ -6786,6 +6787,7 @@ tests/tbs/tb0542.pp svneol=native#text/plain
 tests/tbs/tb0544.pp svneol=native#text/plain
 tests/tbs/tb0545.pp svneol=native#text/plain
 tests/tbs/tb0548.pp svneol=native#text/plain
+tests/tbs/tb0553.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
@@ -7216,6 +7218,7 @@ tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/dumpclass.pp svneol=native#text/plain
 tests/test/dumpmethods.pp svneol=native#text/plain
 tests/test/opt/README -text
+tests/test/opt/tarmshift.pp svneol=native#text/plain
 tests/test/opt/tcmov.pp svneol=native#text/plain
 tests/test/opt/tcse1.pp svneol=native#text/plain
 tests/test/opt/tcse2.pp svneol=native#text/plain
@@ -8005,6 +8008,7 @@ tests/webtbs/tw10519.pp svneol=native#text/plain
 tests/webtbs/tw10540.pp svneol=native#text/plain
 tests/webtbs/tw1061.pp svneol=native#text/plain
 tests/webtbs/tw10623.pp svneol=native#text/plain
+tests/webtbs/tw10641.pp svneol=native#text/plain
 tests/webtbs/tw1066a.pp svneol=native#text/plain
 tests/webtbs/tw1066b.pp svneol=native#text/plain
 tests/webtbs/tw1068.pp svneol=native#text/plain
@@ -8061,6 +8065,7 @@ tests/webtbs/tw11435b.pp svneol=native#text/plain
 tests/webtbs/tw11435c.pp svneol=native#text/plain
 tests/webtbs/tw11436.pp svneol=native#text/plain
 tests/webtbs/tw1152.pp svneol=native#text/plain
+tests/webtbs/tw11543.pp svneol=native#text/plain
 tests/webtbs/tw1157.pp svneol=native#text/plain
 tests/webtbs/tw1157b.pp svneol=native#text/plain
 tests/webtbs/tw11619.pp svneol=native#text/plain

+ 20 - 0
compiler/arm/aoptcpu.pas

@@ -40,6 +40,7 @@ Type
 Implementation
 
   uses
+    verbose,
     aasmbase,aasmcpu;
 
   function CanBeCond(p : tai) : boolean;
@@ -51,6 +52,7 @@ Implementation
   function TCpuAsmOptimizer.PeepHoleOptPass1Cpu(var p: tai): boolean;
     var
       next1: tai;
+      hp1: tai;
     begin
       result := false;
       case p.typ of
@@ -82,6 +84,24 @@ Implementation
                      (taicpu(p).oper[2]^.shifterop^.shiftmode=taicpu(next1).oper[2]^.shifterop^.shiftmode) then
                     begin
                       inc(taicpu(p).oper[2]^.shifterop^.shiftimm,taicpu(next1).oper[2]^.shifterop^.shiftimm);
+                      { avoid overflows }
+                      if taicpu(p).oper[2]^.shifterop^.shiftimm>31 then
+                        case taicpu(p).oper[2]^.shifterop^.shiftmode of
+                          SM_ROR:
+                            taicpu(p).oper[2]^.shifterop^.shiftimm:=taicpu(p).oper[2]^.shifterop^.shiftimm and 31;
+                          SM_ASR:
+                            taicpu(p).oper[2]^.shifterop^.shiftimm:=31;
+                          SM_LSR,
+                          SM_LSL:
+                            begin
+                              hp1:=taicpu.op_reg_const(A_MOV,taicpu(p).oper[0]^.reg,0);
+                              InsertLLItem(p.previous, p.next, hp1);
+                              p.free;
+                              p:=hp1;
+                            end;
+                          else
+                            internalerror(2008072803);
+                        end;
                       asml.remove(next1);
                       next1.free;
                       result := true;

+ 1 - 1
compiler/defcmp.pas

@@ -454,7 +454,7 @@ implementation
                            eq:=te_convert_l1
                          else
                            { size of widechar array is double due the sizeof a widechar }
-                           if not(is_shortstring(def_to) and (def_from.size>255*sizeof(widechar))) then
+                           if not(is_shortstring(def_to) and (is_open_widechararray(def_from) or (def_from.size>255*sizeof(widechar)))) then
                              eq:=te_convert_l3
                          else
                            eq:=te_convert_l2;

+ 3 - 1
compiler/ncgflw.pas

@@ -1471,7 +1471,9 @@ implementation
          { finally code }
          flowcontrol:=[fc_inflowcontrol];
          secondpass(right);
-         if flowcontrol<>[fc_inflowcontrol] then
+         { goto is allowed if it stays inside the finally block,
+           this is checked using the exception block number }
+         if (flowcontrol-[fc_gotolabel])<>[fc_inflowcontrol] then
            CGMessage(cg_e_control_flow_outside_finally);
          if codegenerror then
            exit;

+ 1 - 1
compiler/ncgutil.pas

@@ -2243,7 +2243,7 @@ implementation
               staticvarsym :
                 begin
                   vs:=tabstractnormalvarsym(sym);
-                  { The code in laodnode.pass_generatecode will create the
+                  { The code in loadnode.pass_generatecode will create the
                     LOC_REFERENCE instead for all none register variables. This is
                     required because we can't store an asmsymbol in the localloc because
                     the asmsymbol is invalid after an unit is compiled. This gives

+ 1 - 1
compiler/nld.pas

@@ -315,7 +315,7 @@ implementation
              end;
            procsym :
              begin
-               { Return the first procdef. In case of overlaoded
+               { Return the first procdef. In case of overloaded
                  procdefs the matching procdef will be choosen
                  when the expected procvardef is known, see get_information
                  in htypechk.pas (PFV) }

+ 7 - 0
compiler/ogcoff.pas

@@ -1012,6 +1012,13 @@ const pemagic : array[0..3] of byte = (
                       CurrObjSec.addsectionreloc(curraddr,CurrObjSec,RELOC_ABSOLUTE);
                       inc(data,symaddr);
                     end;
+{$ifdef x86_64}
+                  RELOC_ABSOLUTE32 :
+                    begin
+                      CurrObjSec.addsectionreloc(curraddr,CurrObjSec,RELOC_ABSOLUTE32);
+                      inc(data,symaddr);
+                    end;
+{$endif x86_64}
                   RELOC_RELATIVE :
                     begin
                       inc(data,symaddr-len-CurrObjSec.Size);

+ 18 - 0
tests/tbf/tb0209.pp

@@ -0,0 +1,18 @@
+{ %fail }
+{$mode objfpc}
+{$goto on}
+var
+  a : longint;
+label
+  g;
+
+begin
+  try
+    a:=2;
+  finally
+    if a>1 then
+      goto g;
+    writeln('Error');
+  end;
+  g:
+end.

+ 17 - 0
tests/tbs/tb0553.pp

@@ -0,0 +1,17 @@
+{$mode objfpc}
+{$goto on}
+var
+  a : longint;
+label
+  g;
+
+begin
+  try
+    a:=2;
+  finally
+    if a>1 then
+      goto g;
+    writeln('Error');
+    g:
+  end;
+end.

+ 12 - 0
tests/test/opt/tarmshift.pp

@@ -0,0 +1,12 @@
+{ %norun }
+{ %opt=-O2 }
+var
+  i : longint;
+
+begin
+  i:=1234;
+  i:=i shl 23;
+  i:=i shl 23;
+  if i<>0 then
+    halt(1);
+end.

+ 21 - 0
tests/webtbs/tw10641.pp

@@ -0,0 +1,21 @@
+{ %cpu=x86_64 }
+var
+  test : dword;
+
+begin
+  test:=$deadbeef;
+  ASM
+    MOVL $0,%EAX
+    JMP .LLT(%RAX)
+    .align 16
+.LLT:
+    .quad .L1,.L2
+.L2:
+    MOVL $12341234,test
+.L1:
+    MOVL $0,test
+  END;
+  if test<>0 then
+    halt(1);
+  writeln('ok');
+end.

+ 24 - 0
tests/webtbs/tw11543.pp

@@ -0,0 +1,24 @@
+unit test;
+{$ifdef fpc}{$mode objfpc}{$endif}
+
+interface
+
+type
+  TSetOfChar = set of char;
+
+  ttestclass = class(tobject)
+    procedure p(const a: array of WideChar); overload;
+    procedure p(const a: TSetOfChar); overload;
+  end;
+
+implementation
+
+procedure ttestclass.p(const a: array of WideChar);
+begin
+end;
+
+procedure ttestclass.p(const a: TSetOfChar);
+begin
+end;
+
+end.