Browse Source

* redefine also PPChar and PPPChar depending on the string type mode, resolves #40491

florian 1 year ago
parent
commit
b2a13077c0
3 changed files with 21 additions and 1 deletions
  1. 2 0
      rtl/inc/uachar.pp
  2. 2 1
      rtl/inc/uuchar.pp
  3. 17 0
      tests/webtbs/tw40491.pp

+ 2 - 0
rtl/inc/uachar.pp

@@ -22,6 +22,8 @@ interface
   type
     Char = AnsiChar;
     PChar = PAnsiChar;
+    PPChar = ^PChar;
+    PPPChar = ^PPChar;
 
 implementation
 

+ 2 - 1
rtl/inc/uuchar.pp

@@ -20,7 +20,8 @@ interface
   type
     Char = widechar;
     PChar = pwidechar;
-
+    PPChar = ^PChar;
+    PPPChar = ^PPChar;
 
 {$ifdef FPC_HAS_FEATURE_COMMANDARGS}
 {$ifdef MSWINDOWS}

+ 17 - 0
tests/webtbs/tw40491.pp

@@ -0,0 +1,17 @@
+program test;
+
+{$MODE OBJFPC}
+{$MODESWITCH UNICODESTRINGS}
+
+var
+  S: string;
+  pS: PChar;
+  ppS: PPChar;
+
+begin
+  S := 'test string';
+  pS := @S[1];
+  ppS := @pS;
+  pS := ppS^;  // Error: Incompatible types: got "PChar" expected "PWideChar"
+  WriteLn(string(pS));
+end.