mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 11:45:32 +02:00
compiler:
- don't parse '(' token after the type declaration inside the type block - replace parse of "string<codepage>" to "type AnsiString(codepage)" for delphi compatibility - fix tests to use "type AnsiString(codepage)" git-svn-id: trunk@19148 -
This commit is contained in:
parent
eca53485b8
commit
8b0cb2c1d5
@ -408,6 +408,7 @@ implementation
|
|||||||
generictypelist : TFPObjectList;
|
generictypelist : TFPObjectList;
|
||||||
generictokenbuf : tdynamicarray;
|
generictokenbuf : tdynamicarray;
|
||||||
vmtbuilder : TVMTBuilder;
|
vmtbuilder : TVMTBuilder;
|
||||||
|
p:tnode;
|
||||||
begin
|
begin
|
||||||
old_block_type:=block_type;
|
old_block_type:=block_type;
|
||||||
{ save unit container of forward declarations -
|
{ save unit container of forward declarations -
|
||||||
@ -536,6 +537,28 @@ implementation
|
|||||||
|
|
||||||
hdef:=tstoreddef(hdef).getcopy;
|
hdef:=tstoreddef(hdef).getcopy;
|
||||||
|
|
||||||
|
{ check if it is an ansistirng(codepage) declaration }
|
||||||
|
if is_ansistring(hdef) and try_to_consume(_LKLAMMER) then
|
||||||
|
begin
|
||||||
|
p:=comp_expr(true,false);
|
||||||
|
consume(_RKLAMMER);
|
||||||
|
if not is_constintnode(p) then
|
||||||
|
begin
|
||||||
|
Message(parser_e_illegal_expression);
|
||||||
|
{ error recovery }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if (tordconstnode(p).value<0) or (tordconstnode(p).value>65535) then
|
||||||
|
begin
|
||||||
|
Message(parser_e_invalid_codepage);
|
||||||
|
tordconstnode(p).value:=0;
|
||||||
|
end;
|
||||||
|
tstringdef(hdef).encoding:=int64(tordconstnode(p).value);
|
||||||
|
end;
|
||||||
|
p.free;
|
||||||
|
end;
|
||||||
|
|
||||||
{ fix name, it is used e.g. for tables }
|
{ fix name, it is used e.g. for tables }
|
||||||
if is_class_or_interface_or_dispinterface(hdef) then
|
if is_class_or_interface_or_dispinterface(hdef) then
|
||||||
with tobjectdef(hdef) do
|
with tobjectdef(hdef) do
|
||||||
|
@ -130,35 +130,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
p.free;
|
p.free;
|
||||||
end
|
end
|
||||||
else if token=_LSHARPBRACKET then
|
|
||||||
begin
|
|
||||||
if not(allowtypedef) then
|
|
||||||
Message(parser_e_no_local_para_def);
|
|
||||||
consume(_LSHARPBRACKET);
|
|
||||||
p:=comp_expr(true,false);
|
|
||||||
if not is_constintnode(p) then
|
|
||||||
begin
|
|
||||||
Message(parser_e_illegal_expression);
|
|
||||||
{ error recovery }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if (tordconstnode(p).value<0) or (tordconstnode(p).value>65535) then
|
|
||||||
begin
|
|
||||||
Message(parser_e_invalid_codepage);
|
|
||||||
tordconstnode(p).value:=0;
|
|
||||||
end;
|
|
||||||
if tordconstnode(p).value=CP_UTF16 then
|
|
||||||
def:=tstringdef.createunicode
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
def:=tstringdef.createansi;
|
|
||||||
tstringdef(def).encoding:=int64(tordconstnode(p).value);
|
|
||||||
end;
|
|
||||||
consume(_RSHARPBRACKET);
|
|
||||||
end;
|
|
||||||
p.free;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if cs_ansistrings in current_settings.localswitches then
|
if cs_ansistrings in current_settings.localswitches then
|
||||||
@ -1522,7 +1493,7 @@ implementation
|
|||||||
(token=_LT) and
|
(token=_LT) and
|
||||||
(m_delphi in current_settings.modeswitches) then
|
(m_delphi in current_settings.modeswitches) then
|
||||||
generate_specialization(hdef,false,'');
|
generate_specialization(hdef,false,'');
|
||||||
if try_to_consume(_LKLAMMER) then
|
if not typeonly and try_to_consume(_LKLAMMER) then
|
||||||
begin
|
begin
|
||||||
p1:=comp_expr(true,false);
|
p1:=comp_expr(true,false);
|
||||||
consume(_RKLAMMER);
|
consume(_RKLAMMER);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<CommandLineParams Value="-n -Fuc:\svn\fpcbranches\classhelpers\rtl\units\i386-win32 -Futests\test -FEtestoutput c:\svn\fpcbranches\classhelpers\tests\test\tchlp84.pp"/>
|
<CommandLineParams Value="-MObjFPC -Scgi -O1 -gl -vewnhi -l -FiD:\programming\laz_svn\fpc_features\cpstr\lib\i386-win32\ -FuD:\programming\laz_svn\cpstr\cpstrnew\ -Fu. -FUD:\programming\laz_svn\fpc_features\cpstr\lib\i386-win32\ -oproject1.exe D:\programming\laz_svn\fpc_features\cpstr\project1.lpr"/>
|
||||||
<LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
@ -64,6 +64,7 @@
|
|||||||
<Linking>
|
<Linking>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<GenerateDebugInfo Value="True"/>
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
<DebugInfoType Value="dsStabs"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
</Linking>
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
|
@ -291,14 +291,14 @@ Type
|
|||||||
UCS4String = array of UCS4Char;
|
UCS4String = array of UCS4Char;
|
||||||
|
|
||||||
{$ifdef FPC_HAS_CPSTRING}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
UTF8String = String<65001>;
|
UTF8String = type AnsiString(65001);
|
||||||
{$else FPC_HAS_CPSTRING}
|
{$else FPC_HAS_CPSTRING}
|
||||||
UTF8String = type ansistring;
|
UTF8String = type ansistring;
|
||||||
{$endif FPC_HAS_CPSTRING}
|
{$endif FPC_HAS_CPSTRING}
|
||||||
PUTF8String = ^UTF8String;
|
PUTF8String = ^UTF8String;
|
||||||
|
|
||||||
{$ifdef FPC_HAS_CPSTRING}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
RawByteString = String<$ffff>;
|
RawByteString = type AnsiString($ffff);
|
||||||
{$else FPC_HAS_CPSTRING}
|
{$else FPC_HAS_CPSTRING}
|
||||||
RawByteString = ansistring;
|
RawByteString = ansistring;
|
||||||
{$endif FPC_HAS_CPSTRING}
|
{$endif FPC_HAS_CPSTRING}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{$CODEPAGE cp437}
|
{$CODEPAGE cp437}
|
||||||
type
|
type
|
||||||
tcpstr437 = string<437>;
|
tcpstr437 = type AnsiString(437);
|
||||||
tcpstr850 = string<850>;
|
tcpstr850 = type AnsiString(850);
|
||||||
var
|
var
|
||||||
a1 : tcpstr437;
|
a1 : tcpstr437;
|
||||||
a2 : utf8string;
|
a2 : utf8string;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{$CODEPAGE cp1251}
|
{$CODEPAGE cp1251}
|
||||||
// file encoding is cp1251
|
// file encoding is cp1251
|
||||||
type
|
type
|
||||||
Cp866String = string<866>;
|
Cp866String = type AnsiString(866);
|
||||||
Cp1251String = string<1251>;
|
Cp1251String = type AnsiString(1251);
|
||||||
|
|
||||||
procedure WriteString(const s: RawByteString);
|
procedure WriteString(const s: RawByteString);
|
||||||
begin
|
begin
|
||||||
|
@ -2,8 +2,8 @@ program test;
|
|||||||
{$CODEPAGE UTF8}
|
{$CODEPAGE UTF8}
|
||||||
// file encoding is UTF8
|
// file encoding is UTF8
|
||||||
type
|
type
|
||||||
CP866String = string<866>;
|
CP866String = type AnsiString(866);
|
||||||
CP1251String = string<1251>;
|
CP1251String = type AnsiString(1251);
|
||||||
|
|
||||||
procedure WriteString(const s: RawByteString);
|
procedure WriteString(const s: RawByteString);
|
||||||
begin
|
begin
|
||||||
|
@ -6,7 +6,7 @@ uses
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -5,8 +5,8 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
ts1251 = type string<1251>;
|
ts1251 = type AnsiString(1251);
|
||||||
var
|
var
|
||||||
a850:ts850;
|
a850:ts850;
|
||||||
a1251 : ts1251;
|
a1251 : ts1251;
|
||||||
|
@ -5,8 +5,8 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
ts1251 = type string<1251>;
|
ts1251 = type AnsiString(1251);
|
||||||
var
|
var
|
||||||
a850:ts850;
|
a850:ts850;
|
||||||
a1251 : ts1251;
|
a1251 : ts1251;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
ts1252 = type string<1252>;
|
ts1252 = type AnsiString(1252);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{$CODEPAGE cp866}
|
{$CODEPAGE cp866}
|
||||||
program tcpstrassignansistr;
|
program tcpstrassignansistr;
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -6,7 +6,7 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
var
|
var
|
||||||
a, b, c : ts866;
|
a, b, c : ts866;
|
||||||
begin
|
begin
|
||||||
|
@ -6,7 +6,7 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
var
|
var
|
||||||
a, b, c : ts866;
|
a, b, c : ts866;
|
||||||
begin
|
begin
|
||||||
|
@ -6,9 +6,9 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
ts1251 = type string<1251>;
|
ts1251 = type AnsiString(1251);
|
||||||
var
|
var
|
||||||
a : ts1251;
|
a : ts1251;
|
||||||
b : ts850;
|
b : ts850;
|
||||||
|
@ -7,7 +7,7 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
var
|
var
|
||||||
a, b, c, d : ts866;
|
a, b, c, d : ts866;
|
||||||
begin
|
begin
|
||||||
|
@ -7,9 +7,9 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
ts850 = type string<850>;
|
ts850 = type AnsiString(850);
|
||||||
ts1251 = type string<1251>;
|
ts1251 = type AnsiString(1251);
|
||||||
var
|
var
|
||||||
a : ts1251;
|
a : ts1251;
|
||||||
b : ts850;
|
b : ts850;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
ts1252 = type string<1252>;
|
ts1252 = type AnsiString(1252);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -5,7 +5,7 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
var
|
var
|
||||||
a866 : ts866;
|
a866 : ts866;
|
||||||
begin
|
begin
|
||||||
|
@ -5,7 +5,7 @@ uses
|
|||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866);
|
||||||
var
|
var
|
||||||
a866 : ts866;
|
a866 : ts866;
|
||||||
begin
|
begin
|
||||||
|
@ -6,8 +6,8 @@ uses
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
type
|
type
|
||||||
ts866 = type string<866>;
|
ts866 = type AnsiString(866)
|
||||||
ts1252 = type string<1252>;
|
ts1252 = type AnsiString(1252);
|
||||||
|
|
||||||
procedure doerror(ANumber : Integer);
|
procedure doerror(ANumber : Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
program tcptypedconst;
|
program tcptypedconst;
|
||||||
|
|
||||||
type
|
type
|
||||||
Str_cp = string<1251>;
|
Str_cp = type AnsiString(1251);
|
||||||
Str_cp850 = string<850>;
|
Str_cp850 = type AnsiString(850);
|
||||||
|
|
||||||
procedure printcontent(p : Pointer; l: integer);
|
procedure printcontent(p : Pointer; l: integer);
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user