From fa1ac2515e313a59026e63912d4d14c25598d328 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 3 Jul 2015 20:19:48 +0000 Subject: [PATCH] * don't look for overloaded operators in case of internally generated type conversions (mantis #28375) git-svn-id: trunk@31191 - --- .gitattributes | 1 + compiler/ncnv.pas | 3 ++- tests/webtbs/tw28475.pp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw28475.pp diff --git a/.gitattributes b/.gitattributes index d1cd59178a..3c75d6f66f 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index e576e3c67c..989419f6bd 100644 --- a/compiler/ncnv.pas +++ b/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); diff --git a/tests/webtbs/tw28475.pp b/tests/webtbs/tw28475.pp new file mode 100644 index 0000000000..62ee1bb989 --- /dev/null +++ b/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.