Browse Source

* apply part of patch by Blaise.ru: check only once whether writable consts are enabled or not by determining the type of the assembly list earlier (it's only not needed in an error case anyway)

Sven/Sarah Barth 3 years ago
parent
commit
bd226c00f1
1 changed files with 10 additions and 8 deletions
  1. 10 8
      compiler/pdecl.pas

+ 10 - 8
compiler/pdecl.pas

@@ -229,8 +229,8 @@ implementation
          first,
          first,
          isgeneric,
          isgeneric,
          skipequal : boolean;
          skipequal : boolean;
-         tclist : tasmlist;
          varspez : tvarspez;
          varspez : tvarspez;
+         asmtype : tasmlisttype;
       begin
       begin
          old_block_type:=block_type;
          old_block_type:=block_type;
          block_type:=bt_const;
          block_type:=bt_const;
@@ -293,9 +293,15 @@ implementation
                    storetokenpos:=current_tokenpos;
                    storetokenpos:=current_tokenpos;
                    current_tokenpos:=filepos;
                    current_tokenpos:=filepos;
                    if not (cs_typed_const_writable in current_settings.localswitches) then
                    if not (cs_typed_const_writable in current_settings.localswitches) then
-                     varspez:=vs_const
+                     begin
+                       varspez:=vs_const;
+                       asmtype:=al_rotypedconsts;
+                     end
                    else
                    else
-                     varspez:=vs_value;
+                     begin
+                       varspez:=vs_value;
+                       asmtype:=al_typedconsts;
+                     end;
                    { if we are dealing with structure const then we need to handle it as a
                    { if we are dealing with structure const then we need to handle it as a
                      structure static variable: create a symbol in unit symtable and a reference
                      structure static variable: create a symbol in unit symtable and a reference
                      to it from the structure or linking will fail }
                      to it from the structure or linking will fail }
@@ -344,11 +350,7 @@ implementation
                     begin
                     begin
                       { get init value }
                       { get init value }
                       consume(_EQ);
                       consume(_EQ);
-                      if (cs_typed_const_writable in current_settings.localswitches) then
-                        tclist:=current_asmdata.asmlists[al_typedconsts]
-                      else
-                        tclist:=current_asmdata.asmlists[al_rotypedconsts];
-                      read_typed_const(tclist,tstaticvarsym(sym),in_structure);
+                      read_typed_const(current_asmdata.asmlists[asmtype],tstaticvarsym(sym),in_structure);
                     end;
                     end;
                 end;
                 end;