Browse Source

* allow and properly handle @classtype(pointerconst).field (mantis #15415)

git-svn-id: trunk@14462 -
Jonas Maebe 15 years ago
parent
commit
1a87386bfe
3 changed files with 18 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/ncgmem.pas
  3. 12 0
      tests/webtbs/tw15415.pp

+ 1 - 0
.gitattributes

@@ -10151,6 +10151,7 @@ tests/webtbs/tw15364.pp svneol=native#text/plain
 tests/webtbs/tw15370.pp svneol=native#text/plain
 tests/webtbs/tw15370.pp svneol=native#text/plain
 tests/webtbs/tw15377.pp svneol=native#text/pascal
 tests/webtbs/tw15377.pp svneol=native#text/pascal
 tests/webtbs/tw1539.pp svneol=native#text/plain
 tests/webtbs/tw1539.pp svneol=native#text/plain
+tests/webtbs/tw15415.pp svneol=native#text/plain
 tests/webtbs/tw1567.pp svneol=native#text/plain
 tests/webtbs/tw1567.pp svneol=native#text/plain
 tests/webtbs/tw1573.pp svneol=native#text/plain
 tests/webtbs/tw1573.pp svneol=native#text/plain
 tests/webtbs/tw1592.pp svneol=native#text/plain
 tests/webtbs/tw1592.pp svneol=native#text/plain

+ 5 - 0
compiler/ncgmem.pas

@@ -308,6 +308,11 @@ implementation
                      location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
                      location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
                      cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base);
                      cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base);
                   end;
                   end;
+                LOC_CONSTANT:
+                  begin
+                    { can happen with @classtype(pointerconst).field }
+                    location.reference.offset:=left.location.value;
+                  end;
                 else
                 else
                   internalerror(2009092401);
                   internalerror(2009092401);
              end;
              end;

+ 12 - 0
tests/webtbs/tw15415.pp

@@ -0,0 +1,12 @@
+{$mode delphi}
+
+type
+ TMyClass = class
+   i, i2 :Integer;
+ end;
+
+begin
+ if ptruint(@TMyClass(pointer(5)).i2)<>(5+sizeof(pointer)+4) then
+   halt(1);
+end.
+