Browse Source

+ thlcgobj.location_force_mem now supports LOC_JUMP as well, resolves #40650

florian 1 year ago
parent
commit
a75e453c30
2 changed files with 32 additions and 0 deletions
  1. 18 0
      compiler/hlcgobj.pas
  2. 14 0
      tests/webtbs/tw40650.pp

+ 18 - 0
compiler/hlcgobj.pas

@@ -4298,6 +4298,7 @@ implementation
       r : treference;
       forcesize: aint;
       hregister: TRegister;
+      hl: TAsmLabel;
     begin
       case l.loc of
         LOC_FPUREGISTER,
@@ -4331,6 +4332,23 @@ implementation
             l.reference:=r;
           end;
 {$endif cpuflags}
+        LOC_JUMP :
+          begin
+            a_label(list,l.truelabel);
+            tg.gethltemp(list,size,size.size,tt_normal,r);
+            if is_cbool(size) then
+              a_load_const_ref(list,size,-1,r)
+            else
+              a_load_const_ref(list,size,1,r);
+            current_asmdata.getjumplabel(hl);
+            a_jmp_always(list,hl);
+            a_label(list,l.falselabel);
+            a_load_const_ref(list,size,0,r);
+            a_label(list,hl);
+
+            location_reset_ref(l,LOC_REFERENCE,l.size,size.alignment,[]);
+            l.reference:=r;
+          end;
         LOC_CONSTANT,
         LOC_REGISTER,
         LOC_CREGISTER,

+ 14 - 0
tests/webtbs/tw40650.pp

@@ -0,0 +1,14 @@
+{$coperators+}
+{$modeswitch arrayoperators}
+ 
+var
+  bools: array of boolean;
+  s: string;
+ 
+begin
+  bools := [];
+  s := 'x';
+  bools += [(s <> '') and (s[1] = 'x')]; // project1.lpr(9,40) Error: Internal error 2011010304
+  if not(bools[0]) then
+    halt(1);
+end.