mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-05 21:46:08 +02:00
+ disallow using sizeof() and bitsizeof() on WebAssembly reference types
This commit is contained in:
parent
edbb865260
commit
5c792c438d
@ -1656,7 +1656,7 @@ parser_e_suspending_externals_not_supported_on_current_platform=03368_E_Declarin
|
|||||||
%
|
%
|
||||||
# Type Checking
|
# Type Checking
|
||||||
#
|
#
|
||||||
# 04132 is the last used one
|
# 04133 is the last used one
|
||||||
#
|
#
|
||||||
% \section{Type checking errors}
|
% \section{Type checking errors}
|
||||||
% This section lists all errors that can occur when type checking is
|
% This section lists all errors that can occur when type checking is
|
||||||
@ -2114,6 +2114,8 @@ type_e_nested_procvar_to_funcref=04131_E_A nested function variable can not be a
|
|||||||
% in design assigning a nested function variable to a function reference is forbidden.
|
% in design assigning a nested function variable to a function reference is forbidden.
|
||||||
type_e_cannot_take_address_of_wasm_externref=04132_E_Cannot take the address of a WebAssembly externref
|
type_e_cannot_take_address_of_wasm_externref=04132_E_Cannot take the address of a WebAssembly externref
|
||||||
% WebAssembly externref types don't have an in-memory representation and therefore, their address cannot be taken.
|
% WebAssembly externref types don't have an in-memory representation and therefore, their address cannot be taken.
|
||||||
|
type_e_cannot_determine_size_of_wasm_reference_type=04133_E_WebAssembly reference types don't have an observable size
|
||||||
|
% WebAssembly reference types are opaque, meaning neither their size, nor their bit pattern can be observed.
|
||||||
%
|
%
|
||||||
% \end{description}
|
% \end{description}
|
||||||
#
|
#
|
||||||
|
@ -605,6 +605,7 @@ const
|
|||||||
type_w_array_size_does_not_match_size_of_constant_string=04130;
|
type_w_array_size_does_not_match_size_of_constant_string=04130;
|
||||||
type_e_nested_procvar_to_funcref=04131;
|
type_e_nested_procvar_to_funcref=04131;
|
||||||
type_e_cannot_take_address_of_wasm_externref=04132;
|
type_e_cannot_take_address_of_wasm_externref=04132;
|
||||||
|
type_e_cannot_determine_size_of_wasm_reference_type=04133;
|
||||||
sym_e_id_not_found=05000;
|
sym_e_id_not_found=05000;
|
||||||
sym_f_internal_error_in_symtablestack=05001;
|
sym_f_internal_error_in_symtablestack=05001;
|
||||||
sym_e_duplicate_id=05002;
|
sym_e_duplicate_id=05002;
|
||||||
@ -1166,9 +1167,9 @@ const
|
|||||||
option_info=11024;
|
option_info=11024;
|
||||||
option_help_pages=11025;
|
option_help_pages=11025;
|
||||||
|
|
||||||
MsgTxtSize = 91472;
|
MsgTxtSize = 91538;
|
||||||
|
|
||||||
MsgIdxMax : array[1..20] of longint=(
|
MsgIdxMax : array[1..20] of longint=(
|
||||||
28,109,369,133,102,63,148,38,223,71,
|
28,109,369,134,102,63,148,38,223,71,
|
||||||
68,20,30,1,1,1,1,1,1,1
|
68,20,30,1,1,1,1,1,1,1
|
||||||
);
|
);
|
||||||
|
1126
compiler/msgtxt.inc
1126
compiler/msgtxt.inc
File diff suppressed because it is too large
Load Diff
@ -457,8 +457,13 @@ implementation
|
|||||||
{ allow helpers for SizeOf and BitSizeOf }
|
{ allow helpers for SizeOf and BitSizeOf }
|
||||||
if p1.nodetype=typen then
|
if p1.nodetype=typen then
|
||||||
ttypenode(p1).helperallowed:=true;
|
ttypenode(p1).helperallowed:=true;
|
||||||
|
//Writeln(p1.nodetype, p1.resultdef.typ);
|
||||||
if (p1.resultdef.typ=forwarddef) then
|
if (p1.resultdef.typ=forwarddef) then
|
||||||
Message1(type_e_type_is_not_completly_defined,tforwarddef(p1.resultdef).tosymname^);
|
Message1(type_e_type_is_not_completly_defined,tforwarddef(p1.resultdef).tosymname^);
|
||||||
|
{$ifdef wasm}
|
||||||
|
if is_wasm_reference_type(p1.resultdef) then
|
||||||
|
Message(type_e_cannot_determine_size_of_wasm_reference_type);
|
||||||
|
{$endif wasm}
|
||||||
if (l = in_sizeof_x) or
|
if (l = in_sizeof_x) or
|
||||||
(not((p1.nodetype = vecn) and
|
(not((p1.nodetype = vecn) and
|
||||||
is_packed_array(tvecnode(p1).left.resultdef)) and
|
is_packed_array(tvecnode(p1).left.resultdef)) and
|
||||||
|
11
tests/test/wasm/twasmexternref6.pp
Normal file
11
tests/test/wasm/twasmexternref6.pp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmexternref6;
|
||||||
|
|
||||||
|
const
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
Q = SizeOf(WasmExternRef);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
11
tests/test/wasm/twasmexternref6a.pp
Normal file
11
tests/test/wasm/twasmexternref6a.pp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmexternref6a;
|
||||||
|
|
||||||
|
const
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
Q = BitSizeOf(WasmExternRef);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
15
tests/test/wasm/twasmexternref6b.pp
Normal file
15
tests/test/wasm/twasmexternref6b.pp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmexternref6b;
|
||||||
|
|
||||||
|
procedure test(para: WasmExternRef);
|
||||||
|
var
|
||||||
|
a: longint;
|
||||||
|
begin
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
a := SizeOf(para);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
14
tests/test/wasm/twasmfuncref3.pp
Normal file
14
tests/test/wasm/twasmfuncref3.pp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmfuncref3;
|
||||||
|
|
||||||
|
type
|
||||||
|
TWasmFuncRef = function(a: longint; b: int64): longint; WasmFuncRef;
|
||||||
|
|
||||||
|
const
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
Q = SizeOf(TWasmFuncRef);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
14
tests/test/wasm/twasmfuncref3a.pp
Normal file
14
tests/test/wasm/twasmfuncref3a.pp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmfuncref3a;
|
||||||
|
|
||||||
|
type
|
||||||
|
TWasmFuncRef = function(a: longint; b: int64): longint; WasmFuncRef;
|
||||||
|
|
||||||
|
const
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
Q = BitSizeOf(TWasmFuncRef);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
18
tests/test/wasm/twasmfuncref3b.pp
Normal file
18
tests/test/wasm/twasmfuncref3b.pp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{ %cpu=wasm32 }
|
||||||
|
{ %fail }
|
||||||
|
|
||||||
|
program twasmfuncref3b;
|
||||||
|
|
||||||
|
type
|
||||||
|
TWasmFuncRef = function(a: longint; b: int64): longint; WasmFuncRef;
|
||||||
|
|
||||||
|
procedure test(para: TWasmFuncRef);
|
||||||
|
var
|
||||||
|
a: longint;
|
||||||
|
begin
|
||||||
|
{ Cannot take the size of WebAssembly reference types }
|
||||||
|
a := SizeOf(para);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user