From ffd6a4ea47dda33f7b0259188337fb5dcbd0d086 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 5 Jan 2014 18:26:10 +0000 Subject: [PATCH] * set the code page of rawbytestring typed constants to the same value as when assigning a string constant to a rawbytestring (system code page with {$modeswitch systemcodepage}, CP_ACP without) (mantis #25332) git-svn-id: trunk@26397 - --- .gitattributes | 2 ++ compiler/ngtcon.pas | 6 ++++++ tests/webtbs/tw25332.pp | 9 +++++++++ tests/webtbs/tw25332a.pp | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 tests/webtbs/tw25332.pp create mode 100644 tests/webtbs/tw25332a.pp diff --git a/.gitattributes b/.gitattributes index cbd80bf9a9..f39a39b585 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13757,6 +13757,8 @@ tests/webtbs/tw2525.pp svneol=native#text/plain tests/webtbs/tw25269.pp svneol=native#text/pascal tests/webtbs/tw25289.pp svneol=native#text/plain tests/webtbs/tw25318.pp svneol=native#text/pascal +tests/webtbs/tw25332.pp svneol=native#text/plain +tests/webtbs/tw25332a.pp svneol=native#text/plain tests/webtbs/tw25349.pp svneol=native#text/plain tests/webtbs/tw2536.pp svneol=native#text/plain tests/webtbs/tw25361.pp svneol=native#text/plain diff --git a/compiler/ngtcon.pas b/compiler/ngtcon.pas index 4150d49f52..15069a97ea 100644 --- a/compiler/ngtcon.pas +++ b/compiler/ngtcon.pas @@ -455,6 +455,12 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis begin strlength:=tstringconstnode(node).len; strval:=tstringconstnode(node).value_str; + { the def may have changed from e.g. RawByteString to + AnsiString(CP_ACP) } + if node.resultdef.typ=stringdef then + def:=tstringdef(node.resultdef) + else + internalerror(2014010501); end else begin diff --git a/tests/webtbs/tw25332.pp b/tests/webtbs/tw25332.pp new file mode 100644 index 0000000000..a88182aed1 --- /dev/null +++ b/tests/webtbs/tw25332.pp @@ -0,0 +1,9 @@ + +{mode delphiunicode} + +const r: rawbytestring = 'abc'; +begin + if (stringcodepage(r) <> CP_ACP) and + (stringcodepage(r) <> DefaultSystemCodePage) then + halt(1); +end. diff --git a/tests/webtbs/tw25332a.pp b/tests/webtbs/tw25332a.pp new file mode 100644 index 0000000000..f30175fb6f --- /dev/null +++ b/tests/webtbs/tw25332a.pp @@ -0,0 +1,8 @@ + +{$mode delphiunicode} + +const r: rawbytestring = 'abc'; +begin + if stringcodepage(r) = CP_NONE then + halt(1); +end.