Explorar o código

* 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 %!s(int64=24) %!d(string=hai) anos
pai
achega
2965034fca
Modificáronse 3 ficheiros con 37 adicións e 7 borrados
  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
              calln :
                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? }
                  hp:=tcallnode(left).right;
                  if assigned(hp) then
@@ -449,7 +452,10 @@ implementation
 
         { proc 2 procvar ? }
         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
          if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
           begin
@@ -1034,7 +1040,13 @@ begin
 end.
 {
   $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
 
   Revision 1.24  2001/12/03 21:48:42  peter

+ 13 - 3
compiler/pexpr.pas

@@ -917,11 +917,15 @@ implementation
       begin
         if ((m_tp_procvar in aktmodeswitches) or
             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)
           else
            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);
       end;
 
@@ -2452,7 +2456,13 @@ implementation
 end.
 {
   $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
     * register allocation is now handled by a class and is mostly processor
       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 }
          if (m_tp_procvar in aktmodeswitches) 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
             def_from:=tprocvardef(def_from).rettype.def;
           end;
@@ -1953,7 +1955,13 @@ implementation
 end.
 {
   $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
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead