From 56161e608d9607f011be24f0ea13055c38b7b767 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 12 Jan 2012 21:37:59 +0000 Subject: [PATCH] * do not interpret procsyms followed by ./^/( as potential procvar expressions in case of TP/Mac-style procvar modes (mantis #21073) git-svn-id: trunk@20062 - --- .gitattributes | 1 + compiler/pexpr.pas | 5 +++-- tests/webtbs/tw21073.pp | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/webtbs/tw21073.pp diff --git a/.gitattributes b/.gitattributes index 5e9dd193a1..f8f7a05112 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12118,6 +12118,7 @@ tests/webtbs/tw20995a.pp svneol=native#text/pascal tests/webtbs/tw20995b.pp svneol=native#text/pascal tests/webtbs/tw20998.pp svneol=native#text/pascal tests/webtbs/tw21029.pp svneol=native#text/plain +tests/webtbs/tw21073.pp svneol=native#text/plain tests/webtbs/tw2109.pp svneol=native#text/plain tests/webtbs/tw2110.pp svneol=native#text/plain tests/webtbs/tw2128.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index a3ead1557f..98002d8b10 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -899,8 +899,9 @@ implementation getaddr:=true; end else - if (m_tp_procvar in current_settings.modeswitches) or - (m_mac_procvar in current_settings.modeswitches) then + if ((m_tp_procvar in current_settings.modeswitches) or + (m_mac_procvar in current_settings.modeswitches)) and + not(token in [_CARET,_POINT,_LKLAMMER]) then begin aprocdef:=Tprocsym(sym).Find_procdef_byprocvardef(getprocvardef); if assigned(aprocdef) then diff --git a/tests/webtbs/tw21073.pp b/tests/webtbs/tw21073.pp new file mode 100644 index 0000000000..b13f0cf8d1 --- /dev/null +++ b/tests/webtbs/tw21073.pp @@ -0,0 +1,26 @@ +{ %norun } + +{$mode delphi} + +program gpabugtest; + +TYPE TGetCurrentProcess = function : THandle; stdcall; + TGetProcAddress = function(const hModule : THandle; const lpProcName : PAnsiChar) : Pointer; stdcall; + +function GetProcAddress(const hModule : THandle;const lpProcName : PAnsiChar) : Pointer; stdcall; +begin + result:=nil; +end; + +function GetModuleHandle(const lpModuleName : PWideChar) : THandle; stdcall; +begin + result:=thandle(-1); +end; + +var proc_GetCurrentProcess : TGetCurrentProcess; + proc_GetProcAddress : TGetProcAddress; + +begin + {no error} proc_GetCurrentProcess:=GetProcAddress(GetModuleHandle('Kernel32'),'GetCurrentProcess'); + {error ??} proc_GetProcAddress:= GetProcAddress(GetModuleHandle('Kernel32'),'GetProcAddress'); +end.