Browse Source

* fixed crash with unsupported token overloading

peter 24 years ago
parent
commit
f0e23ff231
2 changed files with 26 additions and 10 deletions
  1. 16 5
      compiler/pdecsub.pas
  2. 10 5
      compiler/symtable.pas

+ 16 - 5
compiler/pdecsub.pas

@@ -679,11 +679,19 @@ begin
                    if lexlevel>normal_function_level then
                      Message(parser_e_no_local_operator);
                    consume(_OPERATOR);
-                   if not(token in [_PLUS..last_overloaded]) then
-                     Message(parser_e_overload_operator_failed);
-                   optoken:=token;
+                   if (token in [_PLUS..last_overloaded]) then
+                    begin
+                      procinfo^.flags:=procinfo^.flags or pi_operator;
+                      optoken:=token;
+                    end
+                   else
+                    begin
+                      Message(parser_e_overload_operator_failed);
+                      { Use the dummy NOTOKEN that is also declared
+                        for the overloaded_operator[] }
+                      optoken:=NOTOKEN;
+                    end;
                    consume(Token);
-                   procinfo^.flags:=procinfo^.flags or pi_operator;
                    parse_proc_head(potype_operator);
                    if token<>_ID then
                      begin
@@ -1864,7 +1872,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.10  2000-12-25 00:07:27  peter
+  Revision 1.11  2001-01-08 21:40:26  peter
+    * fixed crash with unsupported token overloading
+
+  Revision 1.10  2000/12/25 00:07:27  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
 

+ 10 - 5
compiler/symtable.pas

@@ -181,17 +181,19 @@ interface
 
 
     const
-       { last operator which can be overloaded }
+       { last operator which can be overloaded, the first_overloaded should
+         be in tokens.pas after NOTOKEN }
        first_overloaded = _PLUS;
        last_overloaded  = _ASSIGNMENT;
     type
-       toverloaded_operators = array[first_overloaded..last_overloaded] of pprocsym;
+       toverloaded_operators = array[NOTOKEN..last_overloaded] of pprocsym;
     var
        overloaded_operators : toverloaded_operators;
        { unequal is not equal}
     const
-       overloaded_names : array [first_overloaded..last_overloaded] of string[16] =
-         ('plus','minus','star','slash','equal',
+       overloaded_names : array [NOTOKEN..last_overloaded] of string[16] =
+         ('error',
+          'plus','minus','star','slash','equal',
           'greater','lower','greater_or_equal',
           'lower_or_equal',
           'sym_diff','starstar',
@@ -2370,7 +2372,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.23  2000-12-25 00:07:30  peter
+  Revision 1.24  2001-01-08 21:40:27  peter
+    * fixed crash with unsupported token overloading
+
+  Revision 1.23  2000/12/25 00:07:30  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)