mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 11:30:29 +02:00
* correctly simplify tree transforms of (a+c1+c2) if a is a pointer, resolves #37671
git-svn-id: trunk@47437 -
This commit is contained in:
parent
e94fb2edc3
commit
6380df9b42
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -18504,6 +18504,7 @@ tests/webtbs/tw37508.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw3751.pp svneol=native#text/plain
|
tests/webtbs/tw3751.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw37554.pp svneol=native#text/pascal
|
tests/webtbs/tw37554.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3758.pp svneol=native#text/plain
|
tests/webtbs/tw3758.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw37621.pp -text svneol=native#text/pascal
|
||||||
tests/webtbs/tw3764.pp svneol=native#text/plain
|
tests/webtbs/tw3764.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3765.pp svneol=native#text/plain
|
tests/webtbs/tw3765.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw37650.pp svneol=native#text/pascal
|
tests/webtbs/tw37650.pp svneol=native#text/pascal
|
||||||
|
@ -490,7 +490,7 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
t,vl,hp,lefttarget,righttarget: tnode;
|
t,vl,hp,lefttarget,righttarget, hp2: tnode;
|
||||||
lt,rt : tnodetype;
|
lt,rt : tnodetype;
|
||||||
hdef,
|
hdef,
|
||||||
rd,ld , inttype: tdef;
|
rd,ld , inttype: tdef;
|
||||||
@ -793,7 +793,11 @@ implementation
|
|||||||
{ keep the order of val+const else pointer operations might cause an error }
|
{ keep the order of val+const else pointer operations might cause an error }
|
||||||
hp:=taddnode(left).left;
|
hp:=taddnode(left).left;
|
||||||
taddnode(left).left:=right;
|
taddnode(left).left:=right;
|
||||||
left:=left.simplify(forinline);
|
left.resultdef:=nil;
|
||||||
|
do_typecheckpass(left);
|
||||||
|
hp2:=left.simplify(forinline);
|
||||||
|
if assigned(hp2) then
|
||||||
|
left:=hp2;
|
||||||
if resultdef.typ<>pointerdef then
|
if resultdef.typ<>pointerdef then
|
||||||
begin
|
begin
|
||||||
{ ensure that the constant is not expanded to a larger type due to overflow,
|
{ ensure that the constant is not expanded to a larger type due to overflow,
|
||||||
|
@ -4117,7 +4117,9 @@ implementation
|
|||||||
|
|
||||||
function ttypeconvnode.retains_value_location:boolean;
|
function ttypeconvnode.retains_value_location:boolean;
|
||||||
begin
|
begin
|
||||||
result:=(convtype=tc_equal) or
|
result:=assigned(left.resultdef) and
|
||||||
|
(
|
||||||
|
(convtype=tc_equal) or
|
||||||
{ typecasting from void is always allowed }
|
{ typecasting from void is always allowed }
|
||||||
is_void(left.resultdef) or
|
is_void(left.resultdef) or
|
||||||
(left.resultdef.typ=formaldef) or
|
(left.resultdef.typ=formaldef) or
|
||||||
@ -4139,7 +4141,8 @@ implementation
|
|||||||
{ on managed platforms, converting an element to an open array
|
{ on managed platforms, converting an element to an open array
|
||||||
involves creating an actual array -> value location changes }
|
involves creating an actual array -> value location changes }
|
||||||
((convtype=tc_elem_2_openarray) and
|
((convtype=tc_elem_2_openarray) and
|
||||||
not(target_info.system in systems_managed_vm));
|
not(target_info.system in systems_managed_vm))
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
38
tests/webtbs/tw37621.pp
Normal file
38
tests/webtbs/tw37621.pp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
program twctest;
|
||||||
|
|
||||||
|
{$mode delphi}
|
||||||
|
{$define InlineFuncs}
|
||||||
|
|
||||||
|
type
|
||||||
|
REChar = WideChar;
|
||||||
|
TRENextOff = PtrInt;
|
||||||
|
PRegExprChar = PWideChar;
|
||||||
|
TREOp = REChar; // internal p-code type //###0.933
|
||||||
|
|
||||||
|
const
|
||||||
|
REOpSz = SizeOf(TREOp) div SizeOf(REChar);
|
||||||
|
RENextOffSz = (SizeOf(TRENextOff) div SizeOf(REChar));
|
||||||
|
|
||||||
|
function CheckCharCategory(AChar: REChar; Ch0, Ch1: REChar): boolean;
|
||||||
|
// AChar: check this char against opcode
|
||||||
|
// Ch0, Ch1: opcode operands after OP_*CATEGORY
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MatchOneCharCategory(opnd, scan: PRegExprChar): boolean; {$IFDEF InlineFuncs}inline;{$ENDIF}
|
||||||
|
// opnd: points to opcode operands after OP_*CATEGORY
|
||||||
|
// scan: points into InputString
|
||||||
|
begin
|
||||||
|
Result := CheckCharCategory(scan^, opnd^, (opnd + 1)^);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Test;
|
||||||
|
var
|
||||||
|
scan, reginput: PRegExprChar;
|
||||||
|
begin
|
||||||
|
if not MatchOneCharCategory(scan + REOpSz + RENextOffSz, reginput) then Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Test;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user