mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-30 02:02:46 +02:00
* allow type parameters variables being passed to new/dispose, resolves #23270
git-svn-id: trunk@22963 -
This commit is contained in:
parent
49501413e1
commit
d67f31a0e1
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12985,6 +12985,7 @@ tests/webtbs/tw23185.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw2318b.pp svneol=native#text/plain
|
tests/webtbs/tw2318b.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw23212.pp svneol=native#text/plain
|
tests/webtbs/tw23212.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2323.pp svneol=native#text/plain
|
tests/webtbs/tw2323.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw23270.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2328.pp svneol=native#text/plain
|
tests/webtbs/tw2328.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2332.pp svneol=native#text/plain
|
tests/webtbs/tw2332.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2351.pp svneol=native#text/plain
|
tests/webtbs/tw2351.pp svneol=native#text/plain
|
||||||
|
@ -159,6 +159,16 @@ implementation
|
|||||||
destructorpos:=current_tokenpos;
|
destructorpos:=current_tokenpos;
|
||||||
consume(_ID);
|
consume(_ID);
|
||||||
|
|
||||||
|
if is_typeparam(p.resultdef) then
|
||||||
|
begin
|
||||||
|
p.free;
|
||||||
|
p:=factor(false,false);
|
||||||
|
p.free;
|
||||||
|
consume(_RKLAMMER);
|
||||||
|
new_dispose_statement:=cnothingnode.create;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if (p.resultdef.typ<>pointerdef) then
|
if (p.resultdef.typ<>pointerdef) then
|
||||||
begin
|
begin
|
||||||
Message1(type_e_pointer_type_expected,p.resultdef.typename);
|
Message1(type_e_pointer_type_expected,p.resultdef.typename);
|
||||||
@ -278,8 +288,18 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if (p.resultdef.typ<>pointerdef) then
|
if (p.resultdef.typ<>pointerdef) then
|
||||||
Begin
|
Begin
|
||||||
Message1(type_e_pointer_type_expected,p.resultdef.typename);
|
if is_typeparam(p.resultdef) then
|
||||||
new_dispose_statement:=cerrornode.create;
|
begin
|
||||||
|
p.free;
|
||||||
|
consume(_RKLAMMER);
|
||||||
|
new_dispose_statement:=cnothingnode.create;
|
||||||
|
exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Message1(type_e_pointer_type_expected,p.resultdef.typename);
|
||||||
|
new_dispose_statement:=cerrornode.create;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
23
tests/webtbs/tw23270.pp
Normal file
23
tests/webtbs/tw23270.pp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{$MODE DELPHI}
|
||||||
|
|
||||||
|
type
|
||||||
|
TSmallWrapper<TValue> = record
|
||||||
|
Value: TValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TWrapper<T> = class
|
||||||
|
strict private
|
||||||
|
class var FSmallWrapper: TSmallWrapper<PInteger>;
|
||||||
|
public
|
||||||
|
class procedure Z; static;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWrapper<T>.Z;
|
||||||
|
begin
|
||||||
|
FSmallWrapper.Value := New(PInteger);
|
||||||
|
Dispose(FSmallWrapper.Value); { Error: pointer type expected, but ... }
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
TWrapper<Byte>.Z;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user