mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 02:59:33 +02:00
* don't treat bitpacked arrays of subranges of char that can be represented
using less than 8 bits per element the same as regular char arrays as far as automatic type conversions are concerned (they have to be explicitly packed/unpacked) (mantis #24013) git-svn-id: trunk@23739 -
This commit is contained in:
parent
76e6fff302
commit
1244cdff70
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -12179,6 +12179,9 @@ tests/webtbf/tw2359.pp svneol=native#text/plain
|
|||||||
tests/webtbf/tw2362.pp svneol=native#text/plain
|
tests/webtbf/tw2362.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2383.pp svneol=native#text/plain
|
tests/webtbf/tw2383.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2400.pp svneol=native#text/plain
|
tests/webtbf/tw2400.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw24013.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw24013a.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw24013b.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2403.pp svneol=native#text/plain
|
tests/webtbf/tw2403.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2414.pp svneol=native#text/plain
|
tests/webtbf/tw2414.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2478.pp svneol=native#text/plain
|
tests/webtbf/tw2478.pp svneol=native#text/plain
|
||||||
|
@ -547,7 +547,12 @@ implementation
|
|||||||
arraydef :
|
arraydef :
|
||||||
begin
|
begin
|
||||||
{ array of char to string, the length check is done by the firstpass of this node }
|
{ array of char to string, the length check is done by the firstpass of this node }
|
||||||
if is_chararray(def_from) or is_open_chararray(def_from) then
|
if (is_chararray(def_from) or
|
||||||
|
is_open_chararray(def_from)) and
|
||||||
|
{ bitpacked arrays of char whose element bitsize is not
|
||||||
|
8 cannot be auto-converted to strings }
|
||||||
|
(not is_packed_array(def_from) or
|
||||||
|
(tarraydef(def_from).elementdef.packedbitsize=8)) then
|
||||||
begin
|
begin
|
||||||
{ "Untyped" stringconstn is an array of char }
|
{ "Untyped" stringconstn is an array of char }
|
||||||
if fromtreetype=stringconstn then
|
if fromtreetype=stringconstn then
|
||||||
@ -857,12 +862,14 @@ implementation
|
|||||||
{ strings in ISO Pascal (at least if the lower bound }
|
{ strings in ISO Pascal (at least if the lower bound }
|
||||||
{ is 1, but GPC makes all equal-length chararrays }
|
{ is 1, but GPC makes all equal-length chararrays }
|
||||||
{ compatible), so treat those the same as regular }
|
{ compatible), so treat those the same as regular }
|
||||||
{ char arrays }
|
{ char arrays -- except if they use subrange types }
|
||||||
if (is_packed_array(def_from) and
|
if (is_packed_array(def_from) and
|
||||||
not is_chararray(def_from) and
|
(not is_chararray(def_from) or
|
||||||
|
(tarraydef(def_from).elementdef.packedbitsize<>8)) and
|
||||||
not is_widechararray(def_from)) xor
|
not is_widechararray(def_from)) xor
|
||||||
(is_packed_array(def_to) and
|
(is_packed_array(def_to) and
|
||||||
not is_chararray(def_to) and
|
(not is_chararray(def_to) or
|
||||||
|
(tarraydef(def_to).elementdef.packedbitsize<>8)) and
|
||||||
not is_widechararray(def_to)) then
|
not is_widechararray(def_to)) then
|
||||||
{ both must be packed }
|
{ both must be packed }
|
||||||
begin
|
begin
|
||||||
@ -965,7 +972,11 @@ implementation
|
|||||||
else
|
else
|
||||||
{ to array of char, from "Untyped" stringconstn (array of char) }
|
{ to array of char, from "Untyped" stringconstn (array of char) }
|
||||||
if (fromtreetype=stringconstn) and
|
if (fromtreetype=stringconstn) and
|
||||||
(is_chararray(def_to) or
|
((is_chararray(def_to) and
|
||||||
|
{ bitpacked arrays of char whose element bitsize is not
|
||||||
|
8 cannot be auto-converted from strings }
|
||||||
|
(not is_packed_array(def_to) or
|
||||||
|
(tarraydef(def_to).elementdef.packedbitsize=8))) or
|
||||||
is_widechararray(def_to)) then
|
is_widechararray(def_to)) then
|
||||||
begin
|
begin
|
||||||
eq:=te_convert_l1;
|
eq:=te_convert_l1;
|
||||||
@ -1015,8 +1026,12 @@ implementation
|
|||||||
stringdef :
|
stringdef :
|
||||||
begin
|
begin
|
||||||
{ string to char array }
|
{ string to char array }
|
||||||
if (not is_special_array(def_to)) and
|
if not is_special_array(def_to) and
|
||||||
(is_char(tarraydef(def_to).elementdef)or
|
((is_char(tarraydef(def_to).elementdef) and
|
||||||
|
{ bitpacked arrays of char whose element bitsize is not
|
||||||
|
8 cannot be auto-converted from strings }
|
||||||
|
(not is_packed_array(def_to) or
|
||||||
|
(tarraydef(def_to).elementdef.packedbitsize=8))) or
|
||||||
is_widechar(tarraydef(def_to).elementdef)) then
|
is_widechar(tarraydef(def_to).elementdef)) then
|
||||||
begin
|
begin
|
||||||
doconv:=tc_string_2_chararray;
|
doconv:=tc_string_2_chararray;
|
||||||
|
9
tests/webtbf/tw24013.pp
Normal file
9
tests/webtbf/tw24013.pp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
var
|
||||||
|
astr: bitpacked array[1..5] of #0..#127;
|
||||||
|
|
||||||
|
begin
|
||||||
|
writeln('Assigning a literal string to astr:');
|
||||||
|
astr := 'aaaaa';
|
||||||
|
end.
|
11
tests/webtbf/tw24013a.pp
Normal file
11
tests/webtbf/tw24013a.pp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
var
|
||||||
|
astr: bitpacked array[1..5] of #0..#127;
|
||||||
|
str: string;
|
||||||
|
|
||||||
|
begin
|
||||||
|
writeln('Assigning a variable string to astr:');
|
||||||
|
str := 'aaaaa';
|
||||||
|
astr := str;
|
||||||
|
end.
|
13
tests/webtbf/tw24013b.pp
Normal file
13
tests/webtbf/tw24013b.pp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
var
|
||||||
|
astr: bitpacked array[1..5] of #0..#127;
|
||||||
|
str: string;
|
||||||
|
i: integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
writeln('Assigning a bitpacked array to a string variable:');
|
||||||
|
for i := 1 to 5 do
|
||||||
|
astr[i] := 'a';
|
||||||
|
str := astr;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user