mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 15:29:18 +02:00
Merged revision(s) 42776 from trunk:
* fix for Mantis #35981: ensure that the "specialize" token is only really used in non-Delphi modes ........ git-svn-id: branches/fixes_3_2@45994 -
This commit is contained in:
parent
80553119b5
commit
52be8c6631
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -15853,6 +15853,7 @@ tests/webtbf/tw3562.pp svneol=native#text/plain
|
|||||||
tests/webtbf/tw35671.pp svneol=native#text/plain
|
tests/webtbf/tw35671.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw35753.pp svneol=native#text/plain
|
tests/webtbf/tw35753.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw3583.pp svneol=native#text/plain
|
tests/webtbf/tw3583.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw35981.pp svneol=native#text/pascal
|
||||||
tests/webtbf/tw36114.pp svneol=native#text/pascal
|
tests/webtbf/tw36114.pp svneol=native#text/pascal
|
||||||
tests/webtbf/tw3626.pp svneol=native#text/plain
|
tests/webtbf/tw3626.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw3631.pp svneol=native#text/plain
|
tests/webtbf/tw3631.pp svneol=native#text/plain
|
||||||
|
@ -359,7 +359,7 @@ implementation
|
|||||||
if checkcurrentrecdef and
|
if checkcurrentrecdef and
|
||||||
try_parse_structdef_nested_type(def,current_structdef,isforwarddef) then
|
try_parse_structdef_nested_type(def,current_structdef,isforwarddef) then
|
||||||
exit;
|
exit;
|
||||||
if not allowunitsym and (idtoken=_SPECIALIZE) then
|
if not allowunitsym and not (m_delphi in current_settings.modeswitches) and (idtoken=_SPECIALIZE) then
|
||||||
begin
|
begin
|
||||||
consume(_ID);
|
consume(_ID);
|
||||||
is_specialize:=true;
|
is_specialize:=true;
|
||||||
@ -490,7 +490,7 @@ implementation
|
|||||||
|
|
||||||
_ID:
|
_ID:
|
||||||
begin
|
begin
|
||||||
if try_to_consume(_SPECIALIZE) then
|
if not (m_delphi in current_settings.modeswitches) and try_to_consume(_SPECIALIZE) then
|
||||||
begin
|
begin
|
||||||
if ([stoAllowSpecialization,stoAllowTypeDef] * options = []) then
|
if ([stoAllowSpecialization,stoAllowTypeDef] * options = []) then
|
||||||
begin
|
begin
|
||||||
|
40
tests/webtbf/tw35981.pp
Normal file
40
tests/webtbf/tw35981.pp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{ %FAIL }
|
||||||
|
|
||||||
|
program tw35981;
|
||||||
|
|
||||||
|
{$mode Delphi}
|
||||||
|
|
||||||
|
uses Classes;
|
||||||
|
|
||||||
|
type
|
||||||
|
TFoo<T: TPersistent> = class(TPersistent)
|
||||||
|
public
|
||||||
|
C: T;
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFoo<T>.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
C := T.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TFoo<T>.Destroy;
|
||||||
|
begin
|
||||||
|
C.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// note the *working* specialize here, in {$mode Delphi} !!!
|
||||||
|
function Test<T: TPersistent>: specialize TFoo<T>;
|
||||||
|
begin
|
||||||
|
Result := TFoo<T>.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
with Test<TStrings> do begin
|
||||||
|
WriteLn(C.ClassName);
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user