Browse Source

* fixed web bug #1907
* fixed some other procvar related bugs (all related to accepting procvar
constructs with either too many or too little parameters)
(both merged, includes second typo fix of pexpr.pas)

Jonas Maebe 23 years ago
parent
commit
2965034fca
3 changed files with 37 additions and 7 deletions
  1. 14 2
      compiler/nmem.pas
  2. 13 3
      compiler/pexpr.pas
  3. 10 2
      compiler/types.pas

+ 14 - 2
compiler/nmem.pas

@@ -419,6 +419,9 @@ implementation
            case left.nodetype of
            case left.nodetype of
              calln :
              calln :
                begin
                begin
+                 { a load of a procvar can't have parameters }
+                 if assigned(tcallnode(left).left) then
+                   CGMessage(cg_e_illegal_expression);
                  { is it a procvar? }
                  { is it a procvar? }
                  hp:=tcallnode(left).right;
                  hp:=tcallnode(left).right;
                  if assigned(hp) then
                  if assigned(hp) then
@@ -449,7 +452,10 @@ implementation
 
 
         { proc 2 procvar ? }
         { proc 2 procvar ? }
         if left.nodetype=calln then
         if left.nodetype=calln then
-         internalerror(200103253)
+         { if it were a valid construct, the addr node would already have }
+         { been removed in the parser. This happens for (in FPC mode)     }
+         { procvar1 := @procvar2(parameters);                             }
+         CGMessage(cg_e_illegal_expression)
         else
         else
          if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
          if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
           begin
           begin
@@ -1034,7 +1040,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.25  2001-12-06 17:57:34  florian
+  Revision 1.26  2002-04-01 20:57:13  jonas
+    * fixed web bug 1907
+    * fixed some other procvar related bugs (all related to accepting procvar
+        constructs with either too many or too little parameters)
+    (both merged, includes second typo fix of pexpr.pas)
+
+  Revision 1.25  2001/12/06 17:57:34  florian
     + parasym to tparaitem added
     + parasym to tparaitem added
 
 
   Revision 1.24  2001/12/03 21:48:42  peter
   Revision 1.24  2001/12/03 21:48:42  peter

+ 13 - 3
compiler/pexpr.pas

@@ -917,11 +917,15 @@ implementation
       begin
       begin
         if ((m_tp_procvar in aktmodeswitches) or
         if ((m_tp_procvar in aktmodeswitches) or
             not getaddr) then
             not getaddr) then
-          if (p2.nodetype=calln) then
+          if (p2.nodetype=calln) and
+             { a procvar can't have parameters! }
+             not assigned(tcallnode(p2).left) then
            doconv(pv,p2)
            doconv(pv,p2)
           else
           else
            if (p2.nodetype=typeconvn) and
            if (p2.nodetype=typeconvn) and
-              (ttypeconvnode(p2).left.nodetype=calln) then
+              (ttypeconvnode(p2).left.nodetype=calln) and
+              { a procvar can't have parameters! }
+              not assigned(tcallnode(ttypeconvnode(p2).left).left) then
             doconv(pv,ttypeconvnode(p2).left);
             doconv(pv,ttypeconvnode(p2).left);
       end;
       end;
 
 
@@ -2452,7 +2456,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2002-03-31 20:26:35  jonas
+  Revision 1.60  2002-04-01 20:57:13  jonas
+    * fixed web bug 1907
+    * fixed some other procvar related bugs (all related to accepting procvar
+        constructs with either too many or too little parameters)
+    (both merged, includes second typo fix of pexpr.pas)
+
+  Revision 1.59  2002/03/31 20:26:35  jonas
     + a_loadfpu_* and a_loadmm_* methods in tcg
     + a_loadfpu_* and a_loadmm_* methods in tcg
     * register allocation is now handled by a class and is mostly processor
     * register allocation is now handled by a class and is mostly processor
       independent (+rgobj.pas and i386/rgcpu.pas)
       independent (+rgobj.pas and i386/rgcpu.pas)

+ 10 - 2
compiler/types.pas

@@ -1409,7 +1409,9 @@ implementation
          procvar is passed explicit a addrn would be there }
          procvar is passed explicit a addrn would be there }
          if (m_tp_procvar in aktmodeswitches) and
          if (m_tp_procvar in aktmodeswitches) and
             (def_from.deftype=procvardef) and
             (def_from.deftype=procvardef) and
-            (fromtreetype=loadn) then
+            (fromtreetype=loadn) and
+            { only if the procvar doesn't require any paramters }
+            (tprocvardef(def_from).minparacount = 0) then
           begin
           begin
             def_from:=tprocvardef(def_from).rettype.def;
             def_from:=tprocvardef(def_from).rettype.def;
           end;
           end;
@@ -1953,7 +1955,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2002-01-24 18:25:53  peter
+  Revision 1.65  2002-04-01 20:57:14  jonas
+    * fixed web bug 1907
+    * fixed some other procvar related bugs (all related to accepting procvar
+        constructs with either too many or too little parameters)
+    (both merged, includes second typo fix of pexpr.pas)
+
+  Revision 1.64  2002/01/24 18:25:53  peter
    * implicit result variable generation for assembler routines
    * implicit result variable generation for assembler routines
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead