From d89463588c5b9e12950d72aebf4449f6ffbd8627 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 21 Dec 2009 06:57:38 +0000 Subject: [PATCH] compiler: don't compile incorrect statements if operators are involved (issue #0015338) + test git-svn-id: trunk@14458 - --- .gitattributes | 1 + compiler/pstatmnt.pas | 5 ++++- tests/test/toperator7.pp | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/test/toperator7.pp diff --git a/.gitattributes b/.gitattributes index 2cc4e52ca9..b12c648a1d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9083,6 +9083,7 @@ tests/test/toperator3.pp svneol=native#text/plain tests/test/toperator4.pp svneol=native#text/plain tests/test/toperator5.pp svneol=native#text/plain tests/test/toperator6.pp svneol=native#text/plain +tests/test/toperator7.pp svneol=native#text/plain tests/test/tover1.pp svneol=native#text/plain tests/test/tover2.pp svneol=native#text/plain tests/test/tover3.pp svneol=native#text/plain diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 2bf1eae3db..627ae97177 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -1182,7 +1182,10 @@ implementation if not(p.nodetype in [nothingn,errorn,calln,ifn,assignn,breakn,inlinen, continuen,labeln,blockn,exitn]) or ((p.nodetype=inlinen) and - not is_void(p.resultdef)) then + not is_void(p.resultdef)) or + ((p.nodetype=calln) and + (assigned(tcallnode(p).procdefinition)) and + (tcallnode(p).procdefinition.proctypeoption=potype_operator)) then Message(parser_e_illegal_expression); { Specify that we don't use the value returned by the call. diff --git a/tests/test/toperator7.pp b/tests/test/toperator7.pp new file mode 100644 index 0000000000..d5ea5e8f09 --- /dev/null +++ b/tests/test/toperator7.pp @@ -0,0 +1,12 @@ +{%FAIL} +program toperator7; +{$mode objfpc} + +uses + Variants; +var + AValue: Variant; +begin + // this construction must fail + AValue = 1; +end. \ No newline at end of file