* fixed misplaced bracket in condition test that caused all blocks

in libraries to be parsed as if they were the main module block,
    which in practice mainly mean that local variables with default
    values were never initialisation (mantis #16949)

git-svn-id: trunk@15596 -
This commit is contained in:
Jonas Maebe 2010-07-18 09:46:04 +00:00
parent 9affb070b8
commit 5b0962b735
4 changed files with 44 additions and 3 deletions

2
.gitattributes vendored
View File

@ -10544,6 +10544,8 @@ tests/webtbs/tw16861.pp svneol=native#text/plain
tests/webtbs/tw16863.pp svneol=native#text/plain
tests/webtbs/tw16874.pp svneol=native#text/plain
tests/webtbs/tw16901.pp svneol=native#text/plain
tests/webtbs/tw16949a.pp svneol=native#text/plain
tests/webtbs/tw16949b.pp svneol=native#text/plain
tests/webtbs/tw1696.pp svneol=native#text/plain
tests/webtbs/tw1699.pp svneol=native#text/plain
tests/webtbs/tw1709.pp svneol=native#text/plain

View File

@ -186,9 +186,8 @@ implementation
if (
assigned(current_procinfo.procdef.localst) and
(current_procinfo.procdef.localst.symtablelevel=main_program_level) and
(current_module.is_unit)
) or
islibrary then
(current_module.is_unit or islibrary)
) then
begin
if (token=_END) then
begin

19
tests/webtbs/tw16949a.pp Normal file
View File

@ -0,0 +1,19 @@
{ %norun }
{ %target=win32,win64,wince,darwin,linux,freebsd,solaris,beos}
library tw16949a;
{$mode objfpc}{$H+}
function foo: LongInt; cdecl;
var
x: LongInt = 12345;
begin
Result := x;
end;
exports
foo;
begin
end.

21
tests/webtbs/tw16949b.pp Normal file
View File

@ -0,0 +1,21 @@
{ %target=win32,win64,wince,darwin,linux,freebsd,solaris,beos}
{ %needlibrary }
program ptest;
{$ifdef fpc}{$mode objfpc}{$H+}{$endif fpc}
const
{$if defined(windows) or defined(mswindows)}
libname='tw16949a.dll';
{$else}
libname='tw16949a';
{$linklib tw16949a}
{$ifend}
function foo: LongInt; cdecl; external libname;
begin
if foo<>12345 then
halt(1);
end.