* handle absolute on strings correctly for dwarf debug info, resolves #39816

This commit is contained in:
florian 2022-07-05 23:04:17 +02:00
parent a19add9c88
commit e28238da9b
2 changed files with 53 additions and 14 deletions

View File

@ -2200,12 +2200,14 @@ implementation
end; end;
sl_vec: sl_vec:
begin begin
if not assigned(currdef) or if not assigned(currdef) then
(currdef.typ<>arraydef) then
internalerror(2009031201); internalerror(2009031201);
{ can't handle offsets with indirections yet } { can't handle offsets with indirections yet }
if indirection then if indirection then
exit; exit;
case currdef.typ of
arraydef:
begin
if not is_packed_array(currdef) then if not is_packed_array(currdef) then
elesize:=tarraydef(currdef).elesize elesize:=tarraydef(currdef).elesize
else else
@ -2219,6 +2221,32 @@ implementation
inc(offset,(symlist^.value.svalue-tarraydef(currdef).lowrange)*elesize); inc(offset,(symlist^.value.svalue-tarraydef(currdef).lowrange)*elesize);
currdef:=tarraydef(currdef).elementdef; currdef:=tarraydef(currdef).elementdef;
end; end;
stringdef:
begin
case tstringdef(currdef).stringtype of
st_widestring,st_unicodestring:
begin
inc(offset,(symlist^.value.svalue-1)*2);
currdef:=cwidechartype;
end;
st_shortstring:
begin
inc(offset,symlist^.value.svalue);
currdef:=cansichartype;
end;
st_ansistring:
begin
inc(offset,symlist^.value.svalue-1);
currdef:=cansichartype;
end;
else
Internalerror(2022070502);
end;
end;
else
internalerror(2022070501);
end;
end;
else else
internalerror(2009031403); internalerror(2009031403);
end; end;

11
tests/webtbs/tw39816.pp Normal file
View File

@ -0,0 +1,11 @@
{ %OPT=-g }
program Project1;
{$mode objfpc}{$H+}
Var
S:String[100];
C:Char absolute S[1];
begin
s:='asdf';
writeln(s);
end.