Przeglądaj źródła

* 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 -

florian 14 lat temu
rodzic
commit
93e53e1990

+ 1 - 0
.gitattributes

@@ -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

+ 1 - 1
compiler/globals.pas

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

+ 3 - 0
compiler/msg/errore.msg

@@ -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

+ 3 - 2
compiler/msgidx.inc

@@ -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
   );

Plik diff jest za duży
+ 348 - 347
compiler/msgtxt.inc


+ 2 - 1
compiler/scandir.pas

@@ -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;

+ 15 - 8
compiler/systems.pas

@@ -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 - 0
tests/webtbf/tw19463.pp

@@ -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.
+

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików