mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* give a compile-time error when trying to define a short/ansistring typed constant
containing unicode strings instead of producing unpredictable behaviour (mantis #16219) git-svn-id: trunk@15240 -
This commit is contained in:
parent
43033bacae
commit
cddb2ffcae
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -9668,6 +9668,8 @@ tests/webtbf/tw1599.pp svneol=native#text/plain
|
|||||||
tests/webtbf/tw1599b.pp svneol=native#text/plain
|
tests/webtbf/tw1599b.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw16022.pp svneol=native#text/plain
|
tests/webtbf/tw16022.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw16203.pp svneol=native#text/plain
|
tests/webtbf/tw16203.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw16219.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw16219a.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw16234.pp svneol=native#text/plain
|
tests/webtbf/tw16234.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw1633.pp svneol=native#text/plain
|
tests/webtbf/tw1633.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw1642.pp svneol=native#text/plain
|
tests/webtbf/tw1642.pp svneol=native#text/plain
|
||||||
|
@ -368,7 +368,7 @@ scanner_w_illegal_warn_identifier=02087_W_Illegal identifier "$1" for $WARN dire
|
|||||||
#
|
#
|
||||||
# Parser
|
# Parser
|
||||||
#
|
#
|
||||||
# 03291 is the last used one
|
# 03293 is the last used one
|
||||||
#
|
#
|
||||||
% \section{Parser messages}
|
% \section{Parser messages}
|
||||||
% This section lists all parser messages. The parser takes care of the
|
% This section lists all parser messages. The parser takes care of the
|
||||||
@ -1310,6 +1310,11 @@ parser_e_no_paras_for_class_destructor=03291_E_Class destructors can't have para
|
|||||||
parser_f_modeswitch_objc_required=03292_F_This construct requires the \{\$modeswitch objectivec1\} mode switch to be active
|
parser_f_modeswitch_objc_required=03292_F_This construct requires the \{\$modeswitch objectivec1\} mode switch to be active
|
||||||
% Objective-Pascal constructs are not supported when \{\$modeswitch ObjectiveC1\}
|
% Objective-Pascal constructs are not supported when \{\$modeswitch ObjectiveC1\}
|
||||||
% is not active.
|
% is not active.
|
||||||
|
parser_e_widestring_to_ansi_compile_time=03293_E_Unicodechar/string constants cannot be converted to ansi/shortstring at compile-time
|
||||||
|
% It is not possible to use unicodechar and unicodestring constants in
|
||||||
|
% constant expressions that have to be converted into an ansistring or shortstring
|
||||||
|
% at compile time, for example inside typed constants. The reason is that the
|
||||||
|
% compiler cannot know what the actual ansi encoding will be at run time.
|
||||||
#
|
#
|
||||||
# Type Checking
|
# Type Checking
|
||||||
#
|
#
|
||||||
|
@ -381,6 +381,7 @@ const
|
|||||||
parser_e_no_paras_for_class_constructor=03290;
|
parser_e_no_paras_for_class_constructor=03290;
|
||||||
parser_e_no_paras_for_class_destructor=03291;
|
parser_e_no_paras_for_class_destructor=03291;
|
||||||
parser_f_modeswitch_objc_required=03292;
|
parser_f_modeswitch_objc_required=03292;
|
||||||
|
parser_e_widestring_to_ansi_compile_time=03293;
|
||||||
type_e_mismatch=04000;
|
type_e_mismatch=04000;
|
||||||
type_e_incompatible_types=04001;
|
type_e_incompatible_types=04001;
|
||||||
type_e_not_equal_types=04002;
|
type_e_not_equal_types=04002;
|
||||||
@ -859,9 +860,9 @@ const
|
|||||||
option_info=11024;
|
option_info=11024;
|
||||||
option_help_pages=11025;
|
option_help_pages=11025;
|
||||||
|
|
||||||
MsgTxtSize = 56399;
|
MsgTxtSize = 56492;
|
||||||
|
|
||||||
MsgIdxMax : array[1..20] of longint=(
|
MsgIdxMax : array[1..20] of longint=(
|
||||||
24,88,293,96,80,51,110,22,202,63,
|
24,88,294,96,80,51,110,22,202,63,
|
||||||
49,20,1,1,1,1,1,1,1,1
|
49,20,1,1,1,1,1,1,1,1
|
||||||
);
|
);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -662,14 +662,21 @@ implementation
|
|||||||
{ convert to the expected string type so that
|
{ convert to the expected string type so that
|
||||||
for widestrings strval is a pcompilerwidestring }
|
for widestrings strval is a pcompilerwidestring }
|
||||||
inserttypeconv(n,def);
|
inserttypeconv(n,def);
|
||||||
if not codegenerror then
|
if (not codegenerror) and
|
||||||
|
(n.nodetype=stringconstn) then
|
||||||
begin
|
begin
|
||||||
strlength:=tstringconstnode(n).len;
|
strlength:=tstringconstnode(n).len;
|
||||||
strval:=tstringconstnode(n).value_str;
|
strval:=tstringconstnode(n).value_str;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ an error occurred trying to convert the result to a string }
|
begin
|
||||||
strlength:=-1;
|
{ an error occurred trying to convert the result to a string }
|
||||||
|
strlength:=-1;
|
||||||
|
{ it's possible that the type conversion could not be
|
||||||
|
evaluated at compile-time }
|
||||||
|
if not codegenerror then
|
||||||
|
CGMessage(parser_e_widestring_to_ansi_compile_time);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else if is_constcharnode(n) then
|
else if is_constcharnode(n) then
|
||||||
begin
|
begin
|
||||||
|
13
tests/webtbf/tw16219.pp
Normal file
13
tests/webtbf/tw16219.pp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
{$h-}
|
||||||
|
const
|
||||||
|
|
||||||
|
aStrArray: array [0..0] of String = (
|
||||||
|
|
||||||
|
#$ffff' '
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
13
tests/webtbf/tw16219a.pp
Normal file
13
tests/webtbf/tw16219a.pp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
{$h+}
|
||||||
|
const
|
||||||
|
|
||||||
|
aStrArray: array [0..0] of String = (
|
||||||
|
|
||||||
|
#$ffff' '
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user