Fix for Mantis #27120.

pdecobj.pas, parse_object_members:
  * also allow class fields for helper types

+ added tests

git-svn-id: trunk@29270 -
This commit is contained in:
svenbarth 2014-12-12 13:57:43 +00:00
parent 43213dc637
commit 7b216d7fa6
4 changed files with 80 additions and 1 deletions

2
.gitattributes vendored
View File

@ -11748,6 +11748,7 @@ tests/test/thlp43.pp svneol=native#text/pascal
tests/test/thlp44.pp svneol=native#text/pascal
tests/test/thlp45.pp svneol=native#text/pascal
tests/test/thlp46.pp svneol=native#text/pascal
tests/test/thlp47.pp svneol=native#text/pascal
tests/test/thlp5.pp svneol=native#text/pascal
tests/test/thlp6.pp svneol=native#text/pascal
tests/test/thlp7.pp svneol=native#text/pascal
@ -14164,6 +14165,7 @@ tests/webtbs/tw2706.pp svneol=native#text/plain
tests/webtbs/tw2707.pp svneol=native#text/plain
tests/webtbs/tw2708.pp svneol=native#text/plain
tests/webtbs/tw2710.pp svneol=native#text/plain
tests/webtbs/tw27120.pp svneol=native#text/pascal
tests/webtbs/tw2713.pp svneol=native#text/plain
tests/webtbs/tw2721.pp svneol=native#text/plain
tests/webtbs/tw2723.pp svneol=native#text/plain

View File

@ -1216,7 +1216,10 @@ implementation
begin
if is_interface(current_structdef) or
is_objc_protocol_or_category(current_structdef) or
is_objectpascal_helper(current_structdef) or
(
is_objectpascal_helper(current_structdef) and
not class_fields
) or
(is_javainterface(current_structdef) and
not(class_fields and final_fields)) then
Message(parser_e_no_vars_in_interfaces);

56
tests/test/thlp47.pp Normal file
View File

@ -0,0 +1,56 @@
{ This tests that class variables for the various helper kinds work correctly }
program thlp47;
{$mode objfpc}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}
type
TObjectHelper = class helper for TObject
public
class procedure Init;
public class var
Value: LongInt;
end;
TGuidHelper = record helper for TGuid
public
class procedure Init; static;
public class var
Value: LongInt;
end;
TLongIntHelper = type helper for LongInt
public
class procedure Init; static;
public class var
Value: LongInt;
end;
class procedure TObjectHelper.Init;
begin
Value := 42;
end;
class procedure TGuidHelper.Init;
begin
Value := 21;
end;
class procedure TLongIntHelper.Init;
begin
Value := 84;
end;
begin
TObject.Init;
if TObject.Value <> 42 then
Halt(1);
TGuid.Init;
if TGuid.Value <> 21 then
Halt(2);
LongInt.Init;
if LongInt.Value <> 84 then
Halt(3);
end.

18
tests/webtbs/tw27120.pp Normal file
View File

@ -0,0 +1,18 @@
{ %NORUN }
program tw27120;
{$mode objfpc}
type
TFoo = class
end;
TBar = class helper for TFoo
private class var
FFoo: TFoo;
end;
begin
end.