Przeglądaj źródła

* if we assign something to a record field whose type is not regable by
itself (e.g. a 3-byte record as field insde a 4 byte record), make
the parent record non-regable either. The reason is that the parent
record will be forced to memory in that case when subscripting, and
the assignment will happen to this temporary memory location.
Fixes tests/test/tw15357.pp on ppc64 when compiled with -O2 and
without -Cg (not sure why enabling PIC disables global regvars)

git-svn-id: trunk@20959 -

Jonas Maebe 13 lat temu
rodzic
commit
5f3db3c1ba
1 zmienionych plików z 11 dodań i 0 usunięć
  1. 11 0
      compiler/htypechk.pas

+ 11 - 0
compiler/htypechk.pas

@@ -1328,6 +1328,17 @@ implementation
                          CGMessagePos(hp.fileinfo,parser_e_packed_element_no_var_addr);
                          CGMessagePos(hp.fileinfo,parser_e_packed_element_no_var_addr);
                      exit;
                      exit;
                    end;
                    end;
+                 { if we assign something to a field of a record that is not
+                   regable, then then the record can't be kept in a regvar,
+                   because we will force the record into memory for this
+                   subscript operation (to a temp location, so the assignment
+                   will happen to the temp and be lost) }
+                 if not gotsubscript and
+                    not gotderef and
+                    not gotvec and
+                    not tstoreddef(hp.resultdef).is_intregable then
+                   make_not_regable(hp,[ra_addr_regable]);
+
                  gotsubscript:=true;
                  gotsubscript:=true;
                  { loop counter? }
                  { loop counter? }
                  if not(Valid_Const in opts) and
                  if not(Valid_Const in opts) and