Browse Source

* property index is always a s32int
* property implementations must match parameters equal

git-svn-id: trunk@1995 -

peter 19 years ago
parent
commit
dfd9b6e862
4 changed files with 65 additions and 8 deletions
  1. 2 0
      .gitattributes
  2. 12 8
      compiler/pdecvar.pas
  3. 26 0
      tests/webtbf/tw4619a.pp
  4. 25 0
      tests/webtbf/tw4619b.pp

+ 2 - 0
.gitattributes

@@ -5912,6 +5912,8 @@ tests/webtbf/tw4445.pp svneol=native#text/plain
 tests/webtbf/tw4529.pp svneol=native#text/plain
 tests/webtbf/tw4529.pp svneol=native#text/plain
 tests/webtbf/tw4569a.pp svneol=native#text/plain
 tests/webtbf/tw4569a.pp svneol=native#text/plain
 tests/webtbf/tw4569b.pp svneol=native#text/plain
 tests/webtbf/tw4569b.pp svneol=native#text/plain
+tests/webtbf/tw4619a.pp -text svneol=unset#text/plain
+tests/webtbf/tw4619b.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 12 - 8
compiler/pdecvar.pas

@@ -345,19 +345,23 @@ implementation
                 begin
                 begin
                    consume(_INDEX);
                    consume(_INDEX);
                    pt:=comp_expr(true);
                    pt:=comp_expr(true);
+                   { Only allow enum and integer indexes. Convert all integer
+                     values to s32int to be compatible with delphi, because the
+                     procedure matching requires equal parameters }
                    if is_constnode(pt) and
                    if is_constnode(pt) and
                       is_ordinal(pt.resulttype.def)
                       is_ordinal(pt.resulttype.def)
-{$ifndef cpu64bit}
-                      and (not is_64bitint(pt.resulttype.def))
-{$endif}
-                      then
-                     p.index:=tordconstnode(pt).value
+                      and (not is_64bitint(pt.resulttype.def)) then
+                     begin
+                       if is_integer(pt.resulttype.def) then
+                         inserttypeconv_internal(pt,s32inttype);
+                       p.index:=tordconstnode(pt).value;
+                     end
                    else
                    else
                      begin
                      begin
                        Message(parser_e_invalid_property_index_value);
                        Message(parser_e_invalid_property_index_value);
                        p.index:=0;
                        p.index:=0;
                      end;
                      end;
-                   p.indextype.setdef(pt.resulttype.def);
+                   p.indextype:=pt.resulttype;
                    include(p.propoptions,ppo_indexed);
                    include(p.propoptions,ppo_indexed);
                    { concat a longint to the para templates }
                    { concat a longint to the para templates }
                    inc(paranr);
                    inc(paranr);
@@ -403,7 +407,7 @@ implementation
                      { we ignore hidden stuff here because the property access symbol might have
                      { we ignore hidden stuff here because the property access symbol might have
                        non default calling conventions which might change the hidden stuff;
                        non default calling conventions which might change the hidden stuff;
                        see tw3216.pp (FK) }
                        see tw3216.pp (FK) }
-                     p.readaccess.procdef:=Tprocsym(sym).search_procdef_bypara(readprocdef.paras,p.proptype.def,[cpo_allowdefaults,cpo_ignorehidden,cpo_allowconvert]);
+                     p.readaccess.procdef:=Tprocsym(sym).search_procdef_bypara(readprocdef.paras,p.proptype.def,[cpo_allowdefaults,cpo_ignorehidden]);
                      if not assigned(p.readaccess.procdef) then
                      if not assigned(p.readaccess.procdef) then
                        Message(parser_e_ill_property_access_sym);
                        Message(parser_e_ill_property_access_sym);
                    end;
                    end;
@@ -447,7 +451,7 @@ implementation
                      { Insert hidden parameters }
                      { Insert hidden parameters }
                      handle_calling_convention(writeprocdef);
                      handle_calling_convention(writeprocdef);
                      { search procdefs matching writeprocdef }
                      { search procdefs matching writeprocdef }
-                     p.writeaccess.procdef:=Tprocsym(sym).search_procdef_bypara(writeprocdef.paras,writeprocdef.rettype.def,[cpo_allowdefaults,cpo_allowconvert]);
+                     p.writeaccess.procdef:=Tprocsym(sym).search_procdef_bypara(writeprocdef.paras,writeprocdef.rettype.def,[cpo_allowdefaults]);
                      if not assigned(p.writeaccess.procdef) then
                      if not assigned(p.writeaccess.procdef) then
                        Message(parser_e_ill_property_access_sym);
                        Message(parser_e_ill_property_access_sym);
                    end;
                    end;

+ 26 - 0
tests/webtbf/tw4619a.pp

@@ -0,0 +1,26 @@
+{ %fail }
+
+{ Source provided for Free Pascal Bug Report 4619 }
+{ Submitted by "Christian Iversen" on  2005-12-19 }
+{ e-mail: [email protected] }
+
+{$mode delphi}
+
+type
+  TStatement = class
+  end;
+
+  TBlock = class(TStatement)
+  protected
+    // The parameter must be Integer instead of LongWord
+    function GetStat(const Index: LongWord): TStatement;
+  public
+    property Statement1: TStatement index 1 read GetStat;
+  end;
+
+    function TBlock.GetStat(const Index: LongWord): TStatement;
+begin
+end;
+
+begin
+end.

+ 25 - 0
tests/webtbf/tw4619b.pp

@@ -0,0 +1,25 @@
+{ %fail }
+
+{ Source provided for Free Pascal Bug Report 4619 }
+{ Submitted by "Christian Iversen" on  2005-12-19 }
+{ e-mail: [email protected] }
+
+{$mode delphi}
+
+type
+  TStatement = class
+  end;
+
+  TBlock = class(TStatement)
+  protected
+    function GetStat(const Index: LongWord): TStatement;
+  public
+    property Statement[const Index: Integer]: TStatement read GetStat; default;
+  end;
+
+    function TBlock.GetStat(const Index: LongWord): TStatement;
+begin
+end;
+
+begin
+end.