mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 11:09:27 +02:00
Fix for Mantis #25604.
nmat.pas: * correctly disable type checks if one of the arguments for MOD, DIV, SHR, SHL, NOT, -X and +X is a generic type parameter + added tests git-svn-id: trunk@27535 -
This commit is contained in:
parent
c623824374
commit
e85075de7f
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -10213,6 +10213,7 @@ tests/tbs/tb0602.pp svneol=native#text/plain
|
||||
tests/tbs/tb0603.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0604.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0605.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0606.pp svneol=native#text/pascal
|
||||
tests/tbs/tb205.pp svneol=native#text/plain
|
||||
tests/tbs/tbs0594.pp svneol=native#text/pascal
|
||||
tests/tbs/ub0060.pp svneol=native#text/plain
|
||||
@ -13900,6 +13901,7 @@ tests/webtbs/tw25551.pp svneol=native#text/plain
|
||||
tests/webtbs/tw25598.pp svneol=native#text/plain
|
||||
tests/webtbs/tw25600.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25603.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25604.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25605.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2561.pp svneol=native#text/plain
|
||||
tests/webtbs/tw25610.pp -text svneol=native#text/plain
|
||||
|
@ -197,6 +197,14 @@ implementation
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
typecheckpass(right);
|
||||
|
||||
{ avoid any problems with type parameters later on }
|
||||
if is_typeparam(left.resultdef) or is_typeparam(right.resultdef) then
|
||||
begin
|
||||
resultdef:=cundefinedtype;
|
||||
exit;
|
||||
end;
|
||||
|
||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||
set_varstate(right,vs_read,[vsf_must_be_valid]);
|
||||
if codegenerror then
|
||||
@ -644,6 +652,14 @@ implementation
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
typecheckpass(right);
|
||||
|
||||
{ avoid any problems with type parameters later on }
|
||||
if is_typeparam(left.resultdef) or is_typeparam(right.resultdef) then
|
||||
begin
|
||||
resultdef:=cundefinedtype;
|
||||
exit;
|
||||
end;
|
||||
|
||||
set_varstate(right,vs_read,[vsf_must_be_valid]);
|
||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||
if codegenerror then
|
||||
@ -818,6 +834,14 @@ implementation
|
||||
begin
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
|
||||
{ avoid any problems with type parameters later on }
|
||||
if is_typeparam(left.resultdef) then
|
||||
begin
|
||||
resultdef:=cundefinedtype;
|
||||
exit;
|
||||
end;
|
||||
|
||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||
if codegenerror then
|
||||
exit;
|
||||
@ -968,6 +992,14 @@ implementation
|
||||
begin
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
|
||||
{ avoid any problems with type parameters later on }
|
||||
if is_typeparam(left.resultdef) then
|
||||
begin
|
||||
resultdef:=cundefinedtype;
|
||||
exit;
|
||||
end;
|
||||
|
||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||
if codegenerror then
|
||||
exit;
|
||||
@ -1144,6 +1176,14 @@ implementation
|
||||
begin
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
|
||||
{ avoid any problems with type parameters later on }
|
||||
if is_typeparam(left.resultdef) then
|
||||
begin
|
||||
resultdef:=cundefinedtype;
|
||||
exit;
|
||||
end;
|
||||
|
||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||
if codegenerror then
|
||||
exit;
|
||||
|
32
tests/tbs/tb0606.pp
Normal file
32
tests/tbs/tb0606.pp
Normal file
@ -0,0 +1,32 @@
|
||||
{ %NORUN }
|
||||
|
||||
program tb0606;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
type
|
||||
TTest<T> = class
|
||||
procedure Test;
|
||||
end;
|
||||
|
||||
procedure TTest<T>.Test;
|
||||
var
|
||||
r: T;
|
||||
i: LongInt;
|
||||
begin
|
||||
r := i div r;
|
||||
r := r div i;
|
||||
r := i mod r;
|
||||
r := r mod i;
|
||||
r := i shl r;
|
||||
r := r shl i;
|
||||
r := i shr r;
|
||||
r := r shr i;
|
||||
r := - r;
|
||||
r := not r;
|
||||
r := + r;
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
end.
|
24
tests/webtbs/tw25604.pp
Normal file
24
tests/webtbs/tw25604.pp
Normal file
@ -0,0 +1,24 @@
|
||||
{ %NORUN }
|
||||
|
||||
program tw25604;
|
||||
|
||||
{$MODE DELPHI}
|
||||
|
||||
type
|
||||
TA<T> = class
|
||||
private
|
||||
F1, F2: T;
|
||||
procedure Foo;
|
||||
end;
|
||||
|
||||
procedure TA<T>.Foo;
|
||||
var
|
||||
b: Integer;
|
||||
begin
|
||||
b := (b and F1) shr F2; // pass
|
||||
b := (b and not F1) or (b shl F2); // Error: Operator is not overloaded: "LongInt" shl "<undefined type>"
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user