Browse Source

* fix for bug #848

pierre 25 years ago
parent
commit
1606fbbef1
1 changed files with 25 additions and 3 deletions
  1. 25 3
      compiler/ra386int.pas

+ 25 - 3
compiler/ra386int.pas

@@ -976,15 +976,19 @@ var
   code : integer;
   code : integer;
   hreg,
   hreg,
   oldbase : tregister;
   oldbase : tregister;
-  GotStar,
+  GotStar,GotOffset,HadVar,
   GotPlus,Negative : boolean;
   GotPlus,Negative : boolean;
 Begin
 Begin
   Consume(AS_LBRACKET);
   Consume(AS_LBRACKET);
   InitRef;
   InitRef;
   GotStar:=false;
   GotStar:=false;
   GotPlus:=true;
   GotPlus:=true;
+  GotOffset:=false;
   Negative:=false;
   Negative:=false;
   repeat
   repeat
+    if GotOffset and (actasmtoken<>AS_ID) then
+      Message(asmr_e_invalid_reference_syntax);
+
     Case actasmtoken of
     Case actasmtoken of
 
 
       AS_ID: { Constant reference expression OR variable reference expression }
       AS_ID: { Constant reference expression OR variable reference expression }
@@ -1013,14 +1017,27 @@ Begin
            end
            end
           else
           else
            Begin
            Begin
-             if hasvar then
+             if hasvar and not GotOffset then
                Message(asmr_e_cant_have_multiple_relocatable_symbols);
                Message(asmr_e_cant_have_multiple_relocatable_symbols);
+             HadVar:=hasvar and GotOffset;
              if negative then
              if negative then
                Message(asmr_e_only_add_relocatable_symbol);
                Message(asmr_e_only_add_relocatable_symbol);
              oldbase:=opr.ref.base;
              oldbase:=opr.ref.base;
              opr.ref.base:=R_NO;
              opr.ref.base:=R_NO;
              if not SetupVar(actasmpattern) then
              if not SetupVar(actasmpattern) then
                Message1(sym_e_unknown_id,actasmpattern);
                Message1(sym_e_unknown_id,actasmpattern);
+             if GotOffset then
+              if hasvar and (opr.ref.base=procinfo^.framepointer) then
+               begin
+                 opr.ref.base:=R_NO;
+                 hasvar:=hadvar;
+               end
+              else
+               begin
+                 if hasvar and hadvar then
+                   Message(asmr_e_cant_have_multiple_relocatable_symbols);
+                 { should we allow ?? }
+               end;
              { is the base register loaded by the var ? }
              { is the base register loaded by the var ? }
              if (opr.ref.base<>R_NO) then
              if (opr.ref.base<>R_NO) then
               begin
               begin
@@ -1040,6 +1057,7 @@ Begin
                 inc(opr.ref.offset,opr.val);
                 inc(opr.ref.offset,opr.val);
               end;
               end;
              Consume(AS_ID);
              Consume(AS_ID);
+             GotOffset:=false;
            end;
            end;
         end;
         end;
 
 
@@ -1119,6 +1137,7 @@ Begin
       AS_OFFSET :
       AS_OFFSET :
         begin
         begin
           Consume(AS_OFFSET);
           Consume(AS_OFFSET);
+          GotOffset:=true;
         end;
         end;
 
 
       AS_TYPE,
       AS_TYPE,
@@ -1783,7 +1802,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2000-02-13 22:46:28  florian
+  Revision 1.60  2000-03-02 11:48:31  pierre
+   * fix for bug 848
+
+  Revision 1.59  2000/02/13 22:46:28  florian
     * fixed an internalerror with writeln
     * fixed an internalerror with writeln
     * fixed arrayconstructor_to_set to force the generation of better code
     * fixed arrayconstructor_to_set to force the generation of better code
       and added a more strict type checking
       and added a more strict type checking