* set addn resultdef when evaluating constant string concatenation

instead of letting the resulting stringconstn decide for itself
    (mantis #14174)

git-svn-id: trunk@13419 -
This commit is contained in:
Jonas Maebe 2009-07-22 16:16:11 +00:00
parent 5eb7a398e0
commit 63ce04fd00
3 changed files with 42 additions and 1 deletions

1
.gitattributes vendored
View File

@ -9211,6 +9211,7 @@ tests/webtbs/tw1414.pp svneol=native#text/plain
tests/webtbs/tw14143.pp svneol=native#text/plain
tests/webtbs/tw14155.pp svneol=native#text/plain
tests/webtbs/tw1416.pp svneol=native#text/plain
tests/webtbs/tw14174.pp svneol=native#text/plain
tests/webtbs/tw1430.pp svneol=native#text/plain
tests/webtbs/tw1433.pp svneol=native#text/plain
tests/webtbs/tw1445.pp svneol=native#text/plain

View File

@ -666,7 +666,11 @@ implementation
begin
case nodetype of
addn :
t:=cstringconstnode.createpchar(concatansistrings(s1,s2,l1,l2),l1+l2);
begin
t:=cstringconstnode.createpchar(concatansistrings(s1,s2,l1,l2),l1+l2);
typecheckpass(t);
tstringconstnode(t).changestringtype(resultdef);
end;
ltn :
t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),booltype,true);
lten :

36
tests/webtbs/tw14174.pp Normal file
View File

@ -0,0 +1,36 @@
program Test;
type
TToken = (
tkNil,tkEOF,tkNumber,tkOpenBrace,tkCloseBrace,
tkPlus,tkMinus,tkTimes,tkSlash,tkCaret,tkSemiColon
);
function TokenToStr(const Token: TToken): String;
function Quote(const S: String): String;
inline; // comment out to avoid the internal error
begin
Quote:='"'+S+'"';
end;
begin
case Token of
tkNil : TokenToStr:=Quote('Unknown');
tkEOF : TokenToStr:=Quote('EOF');
tkNumber : TokenToStr:=Quote('Number');
tkOpenBrace : TokenToStr:=Quote('(');
tkCloseBrace: TokenToStr:=Quote(')');
tkPlus : TokenToStr:=Quote('+');
tkMinus : TokenToStr:=Quote('-');
tkTimes : TokenToStr:=Quote('*');
tkSlash : TokenToStr:=Quote('/');
tkCaret : TokenToStr:=Quote('^');
tkSemiColon : TokenToStr:=Quote(';');
end;
end;
begin
if (TokenToStr(tkNil)<>'"Unknown"') then
halt(1);
end.