* allow also smaller values for code alignment parameters than the current one, resolves #19463

* limit code alignment parameters to power of 2 up to 256
* give an error for an invalid code alignment directive

git-svn-id: trunk@17659 -
This commit is contained in:
florian 2011-06-04 20:56:15 +00:00
parent e94da0b495
commit 93e53e1990
8 changed files with 486 additions and 446 deletions

1
.gitattributes vendored
View File

@ -10672,6 +10672,7 @@ tests/webtbf/tw1905.pp svneol=native#text/plain
tests/webtbf/tw1927.pp svneol=native#text/plain
tests/webtbf/tw1928.pp svneol=native#text/plain
tests/webtbf/tw1939.pp svneol=native#text/plain
tests/webtbf/tw19463.pp svneol=native#text/pascal
tests/webtbf/tw1949.pp svneol=native#text/plain
tests/webtbf/tw1969.pp svneol=native#text/plain
tests/webtbf/tw1995.pp svneol=native#text/plain

View File

@ -1160,7 +1160,7 @@ implementation
else { Error }
UpdateAlignmentStr:=false;
until false;
UpdateAlignment(a,b);
Result:=Result and UpdateAlignment(a,b);
end;

View File

@ -364,6 +364,9 @@ scan_w_multiple_main_name_overrides=02086_W_Overriding name of "main" procedure
% name will be used.
scanner_w_illegal_warn_identifier=02087_W_Illegal identifier "$1" for $WARN directive
% Identifier is not known by a \var{\{\$WARN\}} compiler directive.
scanner_e_illegal_alignment_directive=02088_E_Illegal alignment directive
% The alignment directive is not valid. Either the alignment type is not known or the alignment
% value is not a power of two.
% \end{description}
#
# Parser

View File

@ -107,6 +107,7 @@ const
scan_e_illegal_minfpconstprec=02085;
scan_w_multiple_main_name_overrides=02086;
scanner_w_illegal_warn_identifier=02087;
scanner_e_illegal_alignment_directive=02088;
parser_e_syntax_error=03000;
parser_e_dont_nest_interrupt=03004;
parser_w_proc_directive_ignored=03005;
@ -893,9 +894,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 59465;
MsgTxtSize = 59501;
MsgIdxMax : array[1..20] of longint=(
24,88,311,103,84,54,111,23,202,63,
24,89,311,103,84,54,111,23,202,63,
49,20,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -1330,7 +1330,8 @@ unit scandir;
begin
current_scanner.skipspace;
s:=current_scanner.readcomment;
UpdateAlignmentStr(s,current_settings.alignment);
if not(UpdateAlignmentStr(s,current_settings.alignment)) then
message(scanner_e_illegal_alignment_directive);
end;
procedure dir_codepage;

View File

@ -505,7 +505,7 @@ interface
procedure set_source_info(const ti : tsysteminfo);
procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
function UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo) : boolean;
procedure RegisterTarget(const r:tsysteminfo);
procedure RegisterRes(const r:tresinfo; rcf : TAbstractResourceFileClass);
@ -697,19 +697,26 @@ begin
end;
procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
function UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo) : boolean;
begin
result:=true;
with d do
begin
if (s.procalign in [1,2,4,8,16,32,64,128]) or (s.procalign=256) then
procalign:=s.procalign
else
result:=false;
if (s.loopalign in [1,2,4,8,16,32,64,128]) or (s.loopalign=256) then
loopalign:=s.loopalign
else
result:=false;
if (s.jumpalign in [1,2,4,8,16,32,64,128]) or (s.jumpalign=256) then
jumpalign:=s.jumpalign
else
result:=false;
{ general update rules:
minimum: if higher then update
maximum: if lower then update or if undefined then update }
if s.procalign>procalign then
procalign:=s.procalign;
if s.loopalign>loopalign then
loopalign:=s.loopalign;
if s.jumpalign>jumpalign then
jumpalign:=s.jumpalign;
if s.constalignmin>constalignmin then
constalignmin:=s.constalignmin;
if (constalignmax=0) or

24
tests/webtbf/tw19463.pp Normal file
View File

@ -0,0 +1,24 @@
{ %fail }
{$CODEALIGN 3}
{$CODEALIGN PROC=3}
program test1;
var
v: integer = 1;
procedure A;
begin
Inc(v);
end;
procedure B;
begin
Dec(v);
end;
begin
A;
B;
end.