Browse Source

* fixed addr(procedure), mantis #28775

git-svn-id: trunk@32204 -
nickysn 9 years ago
parent
commit
c25585daee
3 changed files with 35 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 6 2
      compiler/pexpr.pas
  3. 28 0
      tests/test/cg/taddr3.pp

+ 1 - 0
.gitattributes

@@ -11149,6 +11149,7 @@ tests/test/cg/taddint.pp svneol=native#text/plain
 tests/test/cg/taddlong.pp svneol=native#text/plain
 tests/test/cg/taddr1.pp svneol=native#text/plain
 tests/test/cg/taddr2.pp svneol=native#text/plain
+tests/test/cg/taddr3.pp svneol=native#text/plain
 tests/test/cg/taddreal1.pp svneol=native#text/plain
 tests/test/cg/taddreal2.pp svneol=native#text/plain
 tests/test/cg/taddreal3.pp svneol=native#text/plain

+ 6 - 2
compiler/pexpr.pas

@@ -583,9 +583,13 @@ implementation
           in_addr_x :
             begin
               consume(_LKLAMMER);
-              in_args:=true;
-              p1:=comp_expr(true,false);
+              got_addrn:=true;
+              p1:=factor(true,false,false);
+              { inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp }
+              if token<>_RKLAMMER then
+                p1:=sub_expr(opcompare,true,false,p1);
               p1:=caddrnode.create(p1);
+              got_addrn:=false;
               consume(_RKLAMMER);
               statement_syssym:=p1;
             end;

+ 28 - 0
tests/test/cg/taddr3.pp

@@ -0,0 +1,28 @@
+program taddr3;
+
+{$ifndef FPC}
+type
+  codepointer = pointer;
+{$endif}
+
+procedure testproc;
+begin
+end;
+
+function testfunc: codepointer;
+begin
+  testfunc:=nil;
+end;
+
+var
+  p1, p2: codepointer;
+begin
+  p1 := @testproc;
+  p2 := Addr(testproc);
+  if p1<>p2 then
+    Halt(1);
+  p1 := @testfunc;
+  p2 := Addr(testfunc);
+  if p1<>p2 then
+    Halt(2);
+end.