Browse Source

* disallow using inline nodes with a non-void resultdef as statements
(e.g. length, lo/hi, ord, etc). Not the same as mantis #9918, but
somewhat related

git-svn-id: trunk@8770 -

Jonas Maebe 18 years ago
parent
commit
c89ea4412f

+ 4 - 0
.gitattributes

@@ -7496,6 +7496,10 @@ tests/webtbf/tw9522e.pp svneol=native#text/plain
 tests/webtbf/tw9579a.pp svneol=native#text/plain
 tests/webtbf/tw9579b.pp svneol=native#text/plain
 tests/webtbf/tw9894b.pp svneol=native#text/plain
+tests/webtbf/tw9918a.pp svneol=native#text/plain
+tests/webtbf/tw9918b.pp svneol=native#text/plain
+tests/webtbf/tw9918c.pp svneol=native#text/plain
+tests/webtbf/tw9918d.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 3 - 1
compiler/pstatmnt.pas

@@ -1074,7 +1074,9 @@ implementation
              { with a separate statement for each read/write operation (JM)    }
              { the same is true for val() if the third parameter is not 32 bit }
              if not(p.nodetype in [nothingn,calln,ifn,assignn,breakn,inlinen,
-                                   continuen,labeln,blockn,exitn]) then
+                                   continuen,labeln,blockn,exitn]) or
+                ((p.nodetype=inlinen) and
+                 not is_void(p.resultdef)) then
                Message(parser_e_illegal_expression);
 
              { Specify that we don't use the value returned by the call.

+ 9 - 0
tests/webtbf/tw9918a.pp

@@ -0,0 +1,9 @@
+{ %fail }
+
+{$x-}
+
+var
+  a: array of byte;
+begin
+  length(a);
+end.

+ 9 - 0
tests/webtbf/tw9918b.pp

@@ -0,0 +1,9 @@
+{ %fail }
+
+{$x+}
+
+var
+  s: shortstring;
+begin
+  length(s);
+end.

+ 9 - 0
tests/webtbf/tw9918c.pp

@@ -0,0 +1,9 @@
+{ %fail }
+
+{$x+}
+
+var
+  l: longint;
+begin
+  lo(l);
+end.

+ 9 - 0
tests/webtbf/tw9918d.pp

@@ -0,0 +1,9 @@
+{ %fail }
+
+{$x+}
+
+var
+  d: double;
+begin
+  trunc(d);
+end.