Prechádzať zdrojové kódy

Fix for Mantis #29609.

pexpr.pas, factor.factor_read_id:
  * don't use a cloadvmtaddrnode for accessing class properties in records

+ added test

git-svn-id: trunk@33110 -
svenbarth 9 rokov pred
rodič
commit
25744dd3f1
3 zmenil súbory, kde vykonal 28 pridanie a 1 odobranie
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/pexpr.pas
  3. 22 0
      tests/webtbs/tw29609.pp

+ 1 - 0
.gitattributes

@@ -14937,6 +14937,7 @@ tests/webtbs/tw2953.pp svneol=native#text/plain
 tests/webtbs/tw29546.pp svneol=native#text/pascal
 tests/webtbs/tw2956.pp svneol=native#text/plain
 tests/webtbs/tw2958.pp svneol=native#text/plain
+tests/webtbs/tw29609.pp svneol=native#text/pascal
 tests/webtbs/tw2966.pp svneol=native#text/plain
 tests/webtbs/tw2975.pp svneol=native#text/plain
 tests/webtbs/tw2976.pp svneol=native#text/plain

+ 5 - 1
compiler/pexpr.pas

@@ -3093,7 +3093,11 @@ implementation
                           { it as a class member                                }
                           if (assigned(current_structdef) and (current_structdef<>hdef) and is_owned_by(current_structdef,hdef)) or
                              (assigned(current_procinfo) and current_procinfo.get_normal_proc.procdef.no_self_node) then
-                            p1:=cloadvmtaddrnode.create(ctypenode.create(hdef))
+                            begin
+                              p1:=ctypenode.create(hdef);
+                              if not is_record(hdef) then
+                                p1:=cloadvmtaddrnode.create(p1);
+                            end
                           else
                             p1:=load_self_node;
                         { not srsymtable.symtabletype since that can be }

+ 22 - 0
tests/webtbs/tw29609.pp

@@ -0,0 +1,22 @@
+{ %NORUN }
+
+{$mode objfpc}
+{$MODESWITCH AdvancedRecords}
+program tw29609;
+
+
+type t = record
+        class var      v : Boolean;
+        class function f : Boolean;  static;
+        class property p : Boolean  read v;
+        end;
+
+
+class function t.f : Boolean;
+begin
+Result := p;    // "Error: Pointer to object expected"
+end;
+
+
+begin
+end.