Преглед на файлове

* allow taking the address of an indexed array function result
(mantis #16772)

git-svn-id: trunk@15475 -

Jonas Maebe преди 15 години
родител
ревизия
e36857742f
променени са 3 файла, в които са добавени 36 реда и са изтрити 1 реда
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/pexpr.pas
  3. 34 0
      tests/webtbs/tw16772.pp

+ 1 - 0
.gitattributes

@@ -10509,6 +10509,7 @@ tests/webtbs/tw16668.pp svneol=native#text/plain
 tests/webtbs/tw16700.pp svneol=native#text/plain
 tests/webtbs/tw1677.pp svneol=native#text/plain
 tests/webtbs/tw16770.pp svneol=native#text/plain
+tests/webtbs/tw16772.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain

+ 1 - 1
compiler/pexpr.pas

@@ -1635,7 +1635,7 @@ implementation
                     else
                       { regular procedure/function call }
                       do_proc_call(srsym,srsymtable,nil,
-                                   (getaddr and not(token in [_CARET,_POINT])),
+                                   (getaddr and not(token in [_CARET,_POINT,_LECKKLAMMER])),
                                    again,p1,[]);
                   end;
 

+ 34 - 0
tests/webtbs/tw16772.pp

@@ -0,0 +1,34 @@
+{$ifdef fpc}{$mode delphi}{$endif}
+{$ifdef MSWindows}{$apptype console}{$endif}
+uses
+  SysUtils;
+
+type
+  PByteArray=^TByteArray; 
+var
+  g : array [byte] of byte;
+
+function GetArray: PByteArray;
+begin
+  Result:=@g[0];
+end;
+
+var
+  p : PByteArray;
+begin
+  g[0]:=111;
+  g[1]:=221;
+  g[2]:=252;
+  
+  p:=PByteArray(@GetArray[0]);
+  if p[0]<>111 then
+    halt(1);
+
+  p:=PByteArray(@((GetArray))[1]);
+  if p[0]<>221 then
+    halt(2);
+
+  p:=PByteArray(@(GetArray[2])); 
+  if p[0]<>252 then
+    halt(3);
+end.