compiler: don't compile incorrect statements if operators are involved (issue #0015338) + test

git-svn-id: trunk@14458 -
This commit is contained in:
paul 2009-12-21 06:57:38 +00:00
parent 80e2d8f221
commit d89463588c
3 changed files with 17 additions and 1 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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.

12
tests/test/toperator7.pp Normal file
View File

@ -0,0 +1,12 @@
{%FAIL}
program toperator7;
{$mode objfpc}
uses
Variants;
var
AValue: Variant;
begin
// this construction must fail
AValue = 1;
end.