Browse Source

* check for constants with array decl

peter 27 years ago
parent
commit
6df97708c1
1 changed files with 18 additions and 15 deletions
  1. 18 15
      compiler/pdecl.pas

+ 18 - 15
compiler/pdecl.pas

@@ -1763,24 +1763,24 @@ unit pdecl;
                begin
                begin
                   do_firstpass(pt);
                   do_firstpass(pt);
 
 
-                  if (pt^.treetype<>rangen) or
-                     (pt^.left^.treetype<>ordconstn) then
-                    Message(sym_e_error_in_type_def)
+                  if (pt^.treetype=rangen) then
+                   begin
+                     if (pt^.left^.treetype=ordconstn) and
+                        (pt^.right^.treetype=ordconstn) then
+                      begin
+                        lowval:=pt^.left^.value;
+                        highval:=pt^.right^.value;
+                        arraytype:=pt^.right^.resulttype;
+                      end
+                     else
+                      Message(type_e_cant_eval_constant_expr);
+                   end
                   else
                   else
-                    begin
-{$ifndef GDB}
-                      if pt^.right^.resulttype=pdef(s32bitdef) then
-                        pt^.right^.resulttype:=new(porddef,init(s32bit,$80000000,$7fffffff));
-{$endif GDB}
-                      lowval:=pt^.left^.value;
-                      highval:=pt^.right^.value;
-                      arraytype:=pt^.right^.resulttype;
-                    end;
-
+                   Message(sym_e_error_in_type_def)
                end;
                end;
              disposetree(pt);
              disposetree(pt);
-           { create arraydef }
 
 
+           { create arraydef }
              if p=nil then
              if p=nil then
               begin
               begin
                 ap:=new(parraydef,init(lowval,highval,arraytype));
                 ap:=new(parraydef,init(lowval,highval,arraytype));
@@ -2123,7 +2123,10 @@ unit pdecl;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.86  1998-11-28 16:20:52  peter
+  Revision 1.87  1998-11-29 12:42:24  peter
+    * check for constants with array decl
+
+  Revision 1.86  1998/11/28 16:20:52  peter
     + support for dll variables
     + support for dll variables
 
 
   Revision 1.85  1998/11/27 14:34:43  peter
   Revision 1.85  1998/11/27 14:34:43  peter