* prevent that a absolute symbol references itself, resolves #39604

This commit is contained in:
florian 2022-03-06 22:00:19 +01:00
parent ae3c0a2151
commit ae89261008
5 changed files with 588 additions and 567 deletions

View File

@ -445,7 +445,7 @@ scan_e_unexpected_endif=02108_E_$ENDIF directive found without a matching $IF(N)
#
# Parser
#
# 03362 is the last used one
# 03363 is the last used one
#
% \section{Parser messages}
% This section lists all parser messages. The parser takes care of the
@ -1637,6 +1637,8 @@ parser_e_raise_with_noreturn_not_allowed=03361_E_Raise in subroutines declared a
% goto or any other mean. While the compiler cannot detect all such cases some are trivial and the compiler gives an error.
parser_e_section_directive_not_allowed_for_target=03362_E_Directive section not allowed for this target
% Only some targets (e.g. Embedded and FreeRTOS) support the section directive.
parser_e_absolute_sym_cannot_reference_itself=03363_E_Absolute variable cannot reference itself
% Declarations like \var{var i: Integer absolute i;} are not allowed
%
% \end{description}
%

View File

@ -476,6 +476,7 @@ const
parser_e_constructurs_cannot_take_type_parameters=03360;
parser_e_raise_with_noreturn_not_allowed=03361;
parser_e_section_directive_not_allowed_for_target=03362;
parser_e_absolute_sym_cannot_reference_itself=03363;
type_e_mismatch=04000;
type_e_incompatible_types=04001;
type_e_not_equal_types=04002;
@ -1149,9 +1150,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 89374;
MsgTxtSize = 89424;
MsgIdxMax : array[1..20] of longint=(
28,109,363,131,99,63,148,37,223,69,
28,109,364,131,99,63,148,37,223,69,
65,20,30,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -1307,10 +1307,15 @@ implementation
{ we should check the result type of loadn }
if not (tloadnode(hp).symtableentry.typ in [fieldvarsym,staticvarsym,localvarsym,paravarsym,absolutevarsym]) then
Message(parser_e_absolute_only_to_var_or_const);
abssym:=cabsolutevarsym.create(vs.realname,vs.vardef);
abssym.fileinfo:=vs.fileinfo;
abssym.abstyp:=tovar;
abssym.ref:=node_to_propaccesslist(pt);
if vs=tloadnode(hp).symtableentry then
Message(parser_e_absolute_sym_cannot_reference_itself)
else
begin
abssym:=cabsolutevarsym.create(vs.realname,vs.vardef);
abssym.fileinfo:=vs.fileinfo;
abssym.abstyp:=tovar;
abssym.ref:=node_to_propaccesslist(pt);
end;
{ if the sizes are different, can't be a regvar since you }
{ can't be "absolute upper 8 bits of a register" (except }

11
tests/webtbf/tw39604.pp Normal file
View File

@ -0,0 +1,11 @@
{ %fail }
program Project1;
var
Buf: integer absolute Buf;
begin
writeln(Buf); //uncomment and get: test.pas(12,14) Error: Internal error 200104143
Buf := 1; //uncomment and get: test.pas(14,1) Error: Undefined symbol: U_$P$PROJECT1
end. //line 14