From 5ccbeea1d35f39fa805e51a0c72db1f7ec67d322 Mon Sep 17 00:00:00 2001 From: Jonas Maebe <jonas@freepascal.org> Date: Fri, 23 Dec 2005 22:49:15 +0000 Subject: [PATCH] + support for "return x" as equivalent for "exit(x)" in macpas mode git-svn-id: trunk@2042 - --- .gitattributes | 1 + compiler/pexpr.pas | 5 +++++ compiler/tokens.pas | 2 ++ tests/webtbs/tw4136.pp | 11 +++++++++++ 4 files changed, 19 insertions(+) create mode 100644 tests/webtbs/tw4136.pp diff --git a/.gitattributes b/.gitattributes index 6c91a2fc3e..305d98e6a2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6587,6 +6587,7 @@ tests/webtbs/tw4100.pp svneol=native#text/plain tests/webtbs/tw4104.pp svneol=native#text/plain tests/webtbs/tw4115.pp svneol=native#text/plain tests/webtbs/tw4119.pp svneol=native#text/plain +tests/webtbs/tw4136.pp svneol=native#text/plain tests/webtbs/tw4140.pp svneol=native#text/plain tests/webtbs/tw4150.pp svneol=native#text/plain tests/webtbs/tw4151.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 5976de998e..e3bbb7ff1b 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -2016,6 +2016,11 @@ implementation end else case token of + _RETURN : + begin + consume(_RETURN); + p1 := cexitnode.create(comp_expr(true)); + end; _INHERITED : begin again:=true; diff --git a/compiler/tokens.pas b/compiler/tokens.pas index 1ad2b02453..3d87724c2c 100644 --- a/compiler/tokens.pas +++ b/compiler/tokens.pas @@ -167,6 +167,7 @@ type _RECORD, _REPEAT, _RESULT, + _RETURN, _STATIC, _STORED, _STRICT, @@ -411,6 +412,7 @@ const (str:'RECORD' ;special:false;keyword:m_all;op:NOTOKEN), (str:'REPEAT' ;special:false;keyword:m_all;op:NOTOKEN), (str:'RESULT' ;special:false;keyword:m_none;op:NOTOKEN), + (str:'RETURN' ;special:false;keyword:m_mac;op:NOTOKEN), (str:'STATIC' ;special:false;keyword:m_none;op:NOTOKEN), (str:'STORED' ;special:false;keyword:m_none;op:NOTOKEN), (str:'STRICT' ;special:false;keyword:m_none;op:NOTOKEN), diff --git a/tests/webtbs/tw4136.pp b/tests/webtbs/tw4136.pp new file mode 100644 index 0000000000..1280161f37 --- /dev/null +++ b/tests/webtbs/tw4136.pp @@ -0,0 +1,11 @@ +{$mode macpas} +function f: longint; +begin + return 3; +end; + +begin + if f() <> 3 then + halt(1); +end. +