From 63ce04fd00890e1aaf864391996255ea12e19c81 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 22 Jul 2009 16:16:11 +0000 Subject: [PATCH] * set addn resultdef when evaluating constant string concatenation instead of letting the resulting stringconstn decide for itself (mantis #14174) git-svn-id: trunk@13419 - --- .gitattributes | 1 + compiler/nadd.pas | 6 +++++- tests/webtbs/tw14174.pp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw14174.pp diff --git a/.gitattributes b/.gitattributes index 5457b57454..372116a4d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 2feb86df2d..d56286aa72 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -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 : diff --git a/tests/webtbs/tw14174.pp b/tests/webtbs/tw14174.pp new file mode 100644 index 0000000000..bb696e011c --- /dev/null +++ b/tests/webtbs/tw14174.pp @@ -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.