Browse Source

* stricter handling of formal const parameters and IE fixed

florian 21 years ago
parent
commit
c809441611
3 changed files with 64 additions and 78 deletions
  1. 5 21
      compiler/htypechk.pas
  2. 4 55
      compiler/ncon.pas
  3. 55 2
      compiler/node.pas

+ 5 - 21
compiler/htypechk.pas

@@ -1087,27 +1087,8 @@ implementation
 
 
 
 
     function  valid_for_formal_const(p : tnode) : boolean;
     function  valid_for_formal_const(p : tnode) : boolean;
-      var
-        v : boolean;
       begin
       begin
-        { p must have been firstpass'd before }
-        { accept about anything but not a statement ! }
-        case p.nodetype of
-          calln,
-          statementn,
-          addrn :
-           begin
-             { addrn is not allowed as this generate a constant value,
-               but a tp procvar are allowed (PFV) }
-             if nf_procvarload in p.flags then
-              v:=true
-             else
-              v:=false;
-           end;
-          else
-            v:=true;
-        end;
-        valid_for_formal_const:=v;
+        valid_for_formal_const:=is_constnode(p) or is_procsym_load(p) or valid_for_assign(p,[valid_void]);
       end;
       end;
 
 
 
 
@@ -1922,7 +1903,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.88  2004-05-23 18:28:40  peter
+  Revision 1.89  2004-05-24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.88  2004/05/23 18:28:40  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.87  2004/05/23 15:03:40  peter
   Revision 1.87  2004/05/23 15:03:40  peter

+ 4 - 55
compiler/ncon.pas

@@ -161,14 +161,7 @@ interface
 {$else INT64FUNCRESOK}
 {$else INT64FUNCRESOK}
     function get_ordinal_value(p : tnode) : longint;
     function get_ordinal_value(p : tnode) : longint;
 {$endif INT64FUNCRESOK}
 {$endif INT64FUNCRESOK}
-    function is_constnode(p : tnode) : boolean;
-    function is_constintnode(p : tnode) : boolean;
-    function is_constcharnode(p : tnode) : boolean;
-    function is_constrealnode(p : tnode) : boolean;
-    function is_constboolnode(p : tnode) : boolean;
-    function is_constenumnode(p : tnode) : boolean;
     function is_constresourcestringnode(p : tnode) : boolean;
     function is_constresourcestringnode(p : tnode) : boolean;
-    function is_constwidecharnode(p : tnode) : boolean;
     function str_length(p : tnode) : longint;
     function str_length(p : tnode) : longint;
     function is_emptyset(p : tnode):boolean;
     function is_emptyset(p : tnode):boolean;
     function genconstsymtree(p : tconstsym) : tnode;
     function genconstsymtree(p : tconstsym) : tnode;
@@ -219,53 +212,6 @@ implementation
       end;
       end;
 
 
 
 
-    function is_constnode(p : tnode) : boolean;
-      begin
-        is_constnode:=(p.nodetype in [niln,ordconstn,realconstn,stringconstn,setconstn,guidconstn]);
-      end;
-
-
-    function is_constintnode(p : tnode) : boolean;
-      begin
-         is_constintnode:=(p.nodetype=ordconstn) and is_integer(p.resulttype.def);
-      end;
-
-
-    function is_constcharnode(p : tnode) : boolean;
-
-      begin
-         is_constcharnode:=(p.nodetype=ordconstn) and is_char(p.resulttype.def);
-      end;
-
-
-    function is_constwidecharnode(p : tnode) : boolean;
-
-      begin
-         is_constwidecharnode:=(p.nodetype=ordconstn) and is_widechar(p.resulttype.def);
-      end;
-
-
-    function is_constrealnode(p : tnode) : boolean;
-
-      begin
-         is_constrealnode:=(p.nodetype=realconstn);
-      end;
-
-
-    function is_constboolnode(p : tnode) : boolean;
-
-      begin
-         is_constboolnode:=(p.nodetype=ordconstn) and is_boolean(p.resulttype.def);
-      end;
-
-
-    function is_constenumnode(p : tnode) : boolean;
-
-      begin
-         is_constenumnode:=(p.nodetype=ordconstn) and (p.resulttype.def.deftype=enumdef);
-      end;
-
-
     function is_constresourcestringnode(p : tnode) : boolean;
     function is_constresourcestringnode(p : tnode) : boolean;
       begin
       begin
         is_constresourcestringnode:=(p.nodetype=loadn) and
         is_constresourcestringnode:=(p.nodetype=loadn) and
@@ -969,7 +915,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2004-04-29 19:56:37  daniel
+  Revision 1.62  2004-05-24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.61  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
   Revision 1.60  2004/03/23 22:34:49  peter
   Revision 1.60  2004/03/23 22:34:49  peter

+ 55 - 2
compiler/node.pas

@@ -406,12 +406,21 @@ interface
     procedure printnodeunindent;
     procedure printnodeunindent;
     procedure printnode(var t:text;n:tnode);
     procedure printnode(var t:text;n:tnode);
 
 
+    function is_constnode(p : tnode) : boolean;
+    function is_constintnode(p : tnode) : boolean;
+    function is_constcharnode(p : tnode) : boolean;
+    function is_constrealnode(p : tnode) : boolean;
+    function is_constboolnode(p : tnode) : boolean;
+    function is_constenumnode(p : tnode) : boolean;
+    function is_constwidecharnode(p : tnode) : boolean;
 
 
 
 
 implementation
 implementation
 
 
     uses
     uses
-       cutils,verbose,ppu;
+       cutils,verbose,ppu,
+       symconst,
+       defutil;
 
 
     const
     const
       ppunodemarker = 255;
       ppunodemarker = 255;
@@ -552,6 +561,47 @@ implementation
       end;
       end;
 
 
 
 
+    function is_constnode(p : tnode) : boolean;
+      begin
+        is_constnode:=(p.nodetype in [niln,ordconstn,realconstn,stringconstn,setconstn,guidconstn]);
+      end;
+
+
+    function is_constintnode(p : tnode) : boolean;
+      begin
+         is_constintnode:=(p.nodetype=ordconstn) and is_integer(p.resulttype.def);
+      end;
+
+
+    function is_constcharnode(p : tnode) : boolean;
+      begin
+         is_constcharnode:=(p.nodetype=ordconstn) and is_char(p.resulttype.def);
+      end;
+
+
+    function is_constwidecharnode(p : tnode) : boolean;
+      begin
+         is_constwidecharnode:=(p.nodetype=ordconstn) and is_widechar(p.resulttype.def);
+      end;
+
+
+    function is_constrealnode(p : tnode) : boolean;
+      begin
+         is_constrealnode:=(p.nodetype=realconstn);
+      end;
+
+
+    function is_constboolnode(p : tnode) : boolean;
+      begin
+         is_constboolnode:=(p.nodetype=ordconstn) and is_boolean(p.resulttype.def);
+      end;
+
+
+    function is_constenumnode(p : tnode) : boolean;
+      begin
+         is_constenumnode:=(p.nodetype=ordconstn) and (p.resulttype.def.deftype=enumdef);
+      end;
+
 {****************************************************************************
 {****************************************************************************
                                  TNODE
                                  TNODE
  ****************************************************************************}
  ****************************************************************************}
@@ -1082,7 +1132,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.84  2004-05-23 18:28:41  peter
+  Revision 1.85  2004-05-24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.84  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.83  2004/05/23 15:06:21  peter
   Revision 1.83  2004/05/23 15:06:21  peter