Browse Source

+ support for "return" without return value in MacPas mode

git-svn-id: trunk@4933 -
Jonas Maebe 19 years ago
parent
commit
12c76ca1ce
3 changed files with 15 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/pexpr.pas
  3. 10 0
      tests/tbs/tb0505.pp

+ 1 - 0
.gitattributes

@@ -6003,6 +6003,7 @@ tests/tbs/tb0501.pp svneol=native#text/plain
 tests/tbs/tb0502.pp svneol=native#text/plain
 tests/tbs/tb0503.pp svneol=native#text/plain
 tests/tbs/tb0504.pp svneol=native#text/plain
+tests/tbs/tb0505.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 4 - 1
compiler/pexpr.pas

@@ -2120,7 +2120,10 @@ implementation
            _RETURN :
               begin
                 consume(_RETURN);
-                p1 := cexitnode.create(comp_expr(true));
+                if not(token in [_SEMICOLON,_ELSE,_END]) then
+                  p1 := cexitnode.create(comp_expr(true))
+                else
+                  p1 := cexitnode.create(nil);
               end;
            _INHERITED :
              begin

+ 10 - 0
tests/tbs/tb0505.pp

@@ -0,0 +1,10 @@
+{$mode macpas}
+
+procedure test;
+begin
+  return;
+end;
+
+begin
+  test;
+end.