diff --git a/.gitattributes b/.gitattributes index 6d72ce6149..8b3c803d5a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14874,6 +14874,7 @@ tests/webtbs/tw2886.pp svneol=native#text/plain tests/webtbs/tw2891.pp svneol=native#text/plain tests/webtbs/tw2892.pp svneol=native#text/plain tests/webtbs/tw28934.pp svneol=native#text/plain +tests/webtbs/tw28964.pp svneol=native#text/plain tests/webtbs/tw2897.pp svneol=native#text/plain tests/webtbs/tw2899.pp svneol=native#text/plain tests/webtbs/tw29010a.pp svneol=native#text/plain @@ -15590,6 +15591,7 @@ tests/webtbs/uw2738.pp svneol=native#text/plain tests/webtbs/uw2834.pp svneol=native#text/plain tests/webtbs/uw28442.pp svneol=native#text/pascal tests/webtbs/uw28766.pp svneol=native#text/pascal +tests/webtbs/uw28964.pp svneol=native#text/plain tests/webtbs/uw2920.pp svneol=native#text/plain tests/webtbs/uw2956.pp svneol=native#text/plain tests/webtbs/uw2984.pp svneol=native#text/plain diff --git a/compiler/ppu.pas b/compiler/ppu.pas index 1779064401..fab187343f 100644 --- a/compiler/ppu.pas +++ b/compiler/ppu.pas @@ -43,7 +43,7 @@ type {$endif Test_Double_checksum} const - CurrentPPUVersion = 179; + CurrentPPUVersion = 180; { buffer sizes } maxentrysize = 1024; diff --git a/compiler/symsym.pas b/compiler/symsym.pas index f3e3d70fdd..8ad4dbe085 100644 --- a/compiler/symsym.pas +++ b/compiler/symsym.pas @@ -2385,6 +2385,7 @@ implementation conststring, constresourcestring : begin + ppufile.getderef(constdefderef); value.len:=ppufile.getlongint; getmem(pc,value.len+1); ppufile.getdata(pc^,value.len); @@ -2407,6 +2408,7 @@ implementation end; constguid : begin + ppufile.getderef(constdefderef); new(pguid(value.valueptr)); ppufile.getdata(value.valueptr^,sizeof(tguid)); end; @@ -2440,15 +2442,27 @@ implementation procedure tconstsym.buildderef; begin inherited; - if consttyp in [constord,constreal,constpointer,constset] then - constdefderef.build(constdef); + case consttyp of + constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid: + constdefderef.build(constdef); + constwstring: + ; + else + internalerror(2015120802); + end; end; procedure tconstsym.deref; begin - if consttyp in [constord,constreal,constpointer,constset] then - constdef:=tdef(constdefderef.resolve); + case consttyp of + constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid: + constdef:=tdef(constdefderef.resolve); + constwstring: + constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pcompilerwidestring(value.valueptr))); + else + internalerror(2015120801); + end end; @@ -2457,7 +2471,8 @@ implementation inherited ppuwrite(ppufile); ppufile.putbyte(byte(consttyp)); case consttyp of - constnil : ; + constnil : + ppufile.putderef(constdefderef); constord : begin ppufile.putderef(constdefderef); @@ -2470,12 +2485,14 @@ implementation end; constwstring : begin + { no need to store the def, we can reconstruct it } ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr))); ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar)); end; conststring, constresourcestring : begin + ppufile.putderef(constdefderef); ppufile.putlongint(value.len); ppufile.putdata(pchar(value.valueptr)^,value.len); end; @@ -2490,7 +2507,10 @@ implementation ppufile.putnormalset(value.valueptr^); end; constguid : - ppufile.putdata(value.valueptr^,sizeof(tguid)); + begin + ppufile.putderef(constdefderef); + ppufile.putdata(value.valueptr^,sizeof(tguid)); + end; else internalerror(13); end; diff --git a/compiler/utils/ppuutils/ppudump.pp b/compiler/utils/ppuutils/ppudump.pp index 84984db43f..12c03082d6 100644 --- a/compiler/utils/ppuutils/ppudump.pp +++ b/compiler/utils/ppuutils/ppudump.pp @@ -2395,7 +2395,9 @@ begin end; conststring, constresourcestring : - begin + begin + write ([space,' StringType : ']); + readderef('',constdef.TypeRef); len:=getlongint; getmem(pc,len+1); getdata(pc^,len); @@ -2465,7 +2467,8 @@ begin end; constnil: begin - writeln([space,' NIL pointer.']); + write([space,' NIL pointer :']); + readderef('',constdef.TypeRef); constdef.ConstType:=ctPtr; constdef.VInt:=0; end; @@ -2519,8 +2522,10 @@ begin end; constguid: begin + write ([space,' IntfType : ']); + readderef('',constdef.TypeRef); getdata(guid,sizeof(guid)); - write ([space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']); + write ([space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']); for i:=0 to 7 do begin write(hexstr(guid.d4[i],2)); diff --git a/tests/webtbs/tw28964.pp b/tests/webtbs/tw28964.pp new file mode 100644 index 0000000000..d08206f636 --- /dev/null +++ b/tests/webtbs/tw28964.pp @@ -0,0 +1,9 @@ +{ %recompile } + +uses + uw28964; + +begin + if stringcodepage(externalconst)<>CP_UTF8 then + halt(1); +end. diff --git a/tests/webtbs/uw28964.pp b/tests/webtbs/uw28964.pp new file mode 100644 index 0000000000..5e31e2c268 --- /dev/null +++ b/tests/webtbs/uw28964.pp @@ -0,0 +1,12 @@ +unit uw28964; + +interface + +const + ExternalConst = AnsiString('abc'); + nilconst = pbyte(nil); + guid = iunknown; + +implementation + +end.