Просмотр исходного кода

* correct the register size holding a smallset < 4 bytes when using "bt"
on it (mantis #16861)
* fixed some indentation

git-svn-id: trunk@15531 -

Jonas Maebe 15 лет назад
Родитель
Сommit
c6d00a2b1f
3 измененных файлов с 34 добавлено и 17 удалено
  1. 1 0
      .gitattributes
  2. 19 17
      compiler/x86/nx86set.pas
  3. 14 0
      tests/webtbs/tw16861.pp

+ 1 - 0
.gitattributes

@@ -10525,6 +10525,7 @@ tests/webtbs/tw16787.pp svneol=native#text/plain
 tests/webtbs/tw16803.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
 tests/webtbs/tw16820.pp svneol=native#text/plain
+tests/webtbs/tw16861.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain
 tests/webtbs/tw1709.pp svneol=native#text/plain

+ 19 - 17
compiler/x86/nx86set.pas

@@ -446,22 +446,22 @@ implementation
                           cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,right.location.value,hreg2);
                           emit_reg_reg(A_BT,S_L,hreg,hreg2);
                        end;
-                  else
-                    begin
-                       emit_const_ref(A_CMP,TCGSize2OpSize[orgopsize],31,left.location.reference);
-                       cg.a_jmp_flags(current_asmdata.CurrAsmList,F_BE,l);
-                       { reset carry flag }
-                       current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLC,S_NO));
-                       cg.a_jmp_always(current_asmdata.CurrAsmList,l2);
-                       cg.a_label(current_asmdata.CurrAsmList,l);
-                       hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
-                       cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hreg);
-                       { We have to load the value into a register because
-                         btl does not accept values only refs or regs (PFV) }
-                       hreg2:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
-                       cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,right.location.value,hreg2);
-                       emit_reg_reg(A_BT,S_L,hreg,hreg2);
-                    end;
+                     else
+                       begin
+                          emit_const_ref(A_CMP,TCGSize2OpSize[orgopsize],31,left.location.reference);
+                          cg.a_jmp_flags(current_asmdata.CurrAsmList,F_BE,l);
+                          { reset carry flag }
+                          current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLC,S_NO));
+                          cg.a_jmp_always(current_asmdata.CurrAsmList,l2);
+                          cg.a_label(current_asmdata.CurrAsmList,l);
+                          hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
+                          cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hreg);
+                          { We have to load the value into a register because
+                            btl does not accept values only refs or regs (PFV) }
+                          hreg2:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
+                          cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,right.location.value,hreg2);
+                          emit_reg_reg(A_BT,S_L,hreg,hreg2);
+                       end;
                   end;
                   cg.a_label(current_asmdata.CurrAsmList,l2);
                 end { of right.location.loc=LOC_CONSTANT }
@@ -491,7 +491,9 @@ implementation
                else
                 begin
                   location_force_reg(current_asmdata.CurrAsmList,left.location,opsize,false);
-                    register_maybe_adjust_setbase(current_asmdata.CurrAsmList,left.location,setbase);
+                  register_maybe_adjust_setbase(current_asmdata.CurrAsmList,left.location,setbase);
+                  if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+                    location_force_reg(current_asmdata.CurrAsmList,right.location,opsize,true);
                   pleftreg:=left.location.register;
 
                   if (opsize >= OS_S8) or { = if signed }

+ 14 - 0
tests/webtbs/tw16861.pp

@@ -0,0 +1,14 @@
+(*$packset 1 *)
+program test;
+var
+  s8: set of 0..7;
+  b: byte;
+begin
+  b:=17;
+  s8:=[];
+  if b in (s8+[1]) then
+    halt(1);
+  b:=5;
+  if not(b in (s8+[5])) then
+    halt(2);
+end.