Sfoglia il codice sorgente

* don't look for overloaded operators in case of internally generated
type conversions (mantis #28375)

git-svn-id: trunk@31191 -

Jonas Maebe 10 anni fa
parent
commit
fa1ac2515e
3 ha cambiato i file con 27 aggiunte e 1 eliminazioni
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/ncnv.pas
  3. 24 0
      tests/webtbs/tw28475.pp

+ 1 - 0
.gitattributes

@@ -14529,6 +14529,7 @@ tests/webtbs/tw2832.pp svneol=native#text/plain
 tests/webtbs/tw2834.pp svneol=native#text/plain
 tests/webtbs/tw28372.pp svneol=native#text/plain
 tests/webtbs/tw2841.pp svneol=native#text/plain
+tests/webtbs/tw28475.pp svneol=native#text/plain
 tests/webtbs/tw2853.pp svneol=native#text/plain
 tests/webtbs/tw2853a.pp svneol=native#text/plain
 tests/webtbs/tw2853b.pp svneol=native#text/plain

+ 2 - 1
compiler/ncnv.pas

@@ -2168,7 +2168,8 @@ implementation
             cdoptions:=[cdo_allow_variant,cdo_warn_incompatible_univ];
             { overloaded operators require calls, which is not possible inside
               a constant declaration }
-            if block_type<>bt_const then
+            if (block_type<>bt_const) and
+               not(nf_internal in flags) then
               include(cdoptions,cdo_check_operator);
             if nf_explicit in flags then
               include(cdoptions,cdo_explicit);

+ 24 - 0
tests/webtbs/tw28475.pp

@@ -0,0 +1,24 @@
+{ %opt=-g-t }
+
+program trashtest;
+
+{$MODE OBJFPC}
+
+type
+        TTestRec = record
+                Field1 : Int64;
+        end;
+
+operator := (i: TTestRec) fR: Int64;
+begin
+        fR := i.Field1;
+end;
+
+function TestFunc:TTestRec;
+begin //error reported here
+        TestFunc.Field1 := 1;
+end;
+
+begin
+        WriteLn(TestFunc.Field1);
+end.