mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 00:30:34 +02:00
* don't give an internalerror when passing a constant string to an
openstring parameter (mantis #16022) git-svn-id: trunk@15030 -
This commit is contained in:
parent
3ef5d17209
commit
6db635210a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9648,6 +9648,7 @@ tests/webtbf/tw15727b.pp svneol=native#text/plain
|
||||
tests/webtbf/tw15777b.pp svneol=native#text/plain
|
||||
tests/webtbf/tw1599.pp svneol=native#text/plain
|
||||
tests/webtbf/tw1599b.pp svneol=native#text/plain
|
||||
tests/webtbf/tw16022.pp svneol=native#text/plain
|
||||
tests/webtbf/tw1633.pp svneol=native#text/plain
|
||||
tests/webtbf/tw1642.pp svneol=native#text/plain
|
||||
tests/webtbf/tw1655.pp svneol=native#text/plain
|
||||
|
@ -1417,11 +1417,18 @@ implementation
|
||||
len : integer;
|
||||
loadconst : boolean;
|
||||
hightree,l,r : tnode;
|
||||
defkind: tdeftyp;
|
||||
begin
|
||||
len:=-1;
|
||||
loadconst:=true;
|
||||
hightree:=nil;
|
||||
case p.resultdef.typ of
|
||||
{ constant strings are internally stored as array of char, but if the
|
||||
parameter is a string also treat it like one }
|
||||
defkind:=p.resultdef.typ;
|
||||
if (p.nodetype=stringconstn) and
|
||||
(paradef.typ=stringdef) then
|
||||
defkind:=stringdef;
|
||||
case defkind of
|
||||
arraydef :
|
||||
begin
|
||||
if (paradef.typ<>arraydef) then
|
||||
@ -1510,7 +1517,14 @@ implementation
|
||||
begin
|
||||
if is_open_string(paradef) then
|
||||
begin
|
||||
maybe_load_in_temp(p);
|
||||
{ a stringconstn is not a simple parameter and hence would be
|
||||
loaded in a temp, but in that case the high() node
|
||||
a) goes wrong (it cannot deal with a temp node)
|
||||
b) would give a generic result instead of one specific to
|
||||
this constant string
|
||||
}
|
||||
if p.nodetype<>stringconstn then
|
||||
maybe_load_in_temp(p);
|
||||
{ handle via a normal inline in_high_x node }
|
||||
loadconst := false;
|
||||
hightree := geninlinenode(in_high_x,false,p.getcopy);
|
||||
|
17
tests/webtbf/tw16022.pp
Normal file
17
tests/webtbf/tw16022.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{ %fail }
|
||||
|
||||
PROGRAM test;
|
||||
|
||||
{$mode objfpc}
|
||||
var a,b: string;
|
||||
|
||||
begin
|
||||
a:= 'Test A';
|
||||
b:= 'B Test';
|
||||
system.insert(a,'ing',5);
|
||||
system.insert('H World','allo',2);
|
||||
system.insert('&B',b,2);
|
||||
writeln(a);
|
||||
writeln(b);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user