From f22a6629c191c5f4a7e41d0719448316aa2e4157 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 12 Nov 2017 22:14:23 +0000 Subject: [PATCH] * set types correctly for char -> shortstring conversions, resolves #32686 git-svn-id: trunk@37585 - --- compiler/ncnv.pas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 3649ea42f1..b7e704ebe1 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -1183,6 +1183,7 @@ implementation sa : ansistring; cw : tcompilerwidechar; l : SizeUInt; + exprtype : tdef; begin result:=nil; if (left.nodetype=ordconstn) and @@ -1284,16 +1285,22 @@ implementation end else begin + { use at least u16inttype } +{$ifdef cpu8bitalu} + exprtype:=u16inttype; +{$else cpu8bitalu} + exprtype:=uinttype; +{$endif cpu8bitalu} { create word(byte(char) shl 8 or 1) for litte endian machines } { and word(byte(char) or 256) for big endian machines } - left := ctypeconvnode.create_internal(left,u8inttype); + left := ctypeconvnode.create_internal(left,exprtype); if (target_info.endian = endian_little) then left := caddnode.create(orn, - cshlshrnode.create(shln,left,cordconstnode.create(8,s32inttype,false)), - cordconstnode.create(1,s32inttype,false)) + cshlshrnode.create(shln,left,cordconstnode.create(8,exprtype,false)), + cordconstnode.create(1,exprtype,false)) else left := caddnode.create(orn,left, - cordconstnode.create(1 shl 8,s32inttype,false)); + cordconstnode.create(1 shl 8,exprtype,false)); left := ctypeconvnode.create_internal(left,u16inttype); typecheckpass(left); end;