Browse Source

* move check for unused object constructor result to blocknode

peter 22 years ago
parent
commit
fae3eaf83d
2 changed files with 14 additions and 12 deletions
  1. 8 2
      compiler/nbas.pas
  2. 6 10
      compiler/pstatmnt.pas

+ 8 - 2
compiler/nbas.pas

@@ -351,7 +351,10 @@ implementation
                       not(cs_extsyntax in aktmoduleswitches) and
                       not(cs_extsyntax in aktmoduleswitches) and
                       (hp.left.nodetype=calln) and
                       (hp.left.nodetype=calln) and
                       not(is_void(hp.left.resulttype.def)) and
                       not(is_void(hp.left.resulttype.def)) and
-                      not(nf_return_value_used in tcallnode(hp.left).flags) then
+                      not(nf_return_value_used in tcallnode(hp.left).flags) and
+                      not((tcallnode(hp.left).procdefinition.proctypeoption=potype_constructor) and
+                          assigned(tprocdef(tcallnode(hp.left).procdefinition)._class) and
+                          is_object(tprocdef(tcallnode(hp.left).procdefinition)._class)) then
                      CGMessagePos(hp.left.fileinfo,cg_e_illegal_expression);
                      CGMessagePos(hp.left.fileinfo,cg_e_illegal_expression);
                    { the resulttype of the block is the last type that is
                    { the resulttype of the block is the last type that is
                      returned. Normally this is a voidtype. But when the
                      returned. Normally this is a voidtype. But when the
@@ -845,7 +848,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.69  2003-10-23 14:44:07  peter
+  Revision 1.70  2003-10-29 20:34:20  peter
+    * move check for unused object constructor result to blocknode
+
+  Revision 1.69  2003/10/23 14:44:07  peter
     * splitted buildderef and buildderefimpl to fix interface crc
     * splitted buildderef and buildderefimpl to fix interface crc
       calculation
       calculation
 
 

+ 6 - 10
compiler/pstatmnt.pas

@@ -982,15 +982,11 @@ implementation
                                    continuen,labeln,blockn,exitn]) then
                                    continuen,labeln,blockn,exitn]) then
                Message(cg_e_illegal_expression);
                Message(cg_e_illegal_expression);
 
 
-             { specify that we don't use the value returned by the call
-               it is used for :
+             { Specify that we don't use the value returned by the call.
+               This is used for :
                 - dispose of temp stack space
                 - dispose of temp stack space
-                - dispose on FPU stack
-               Object constructor results are ignored }
-             if (p.nodetype=calln) and
-                not((tcallnode(p).procdefinition.proctypeoption=potype_constructor) and
-                    assigned(tprocdef(tcallnode(p).procdefinition)._class) and
-                    is_object(tprocdef(tcallnode(p).procdefinition)._class)) then
+                - dispose on FPU stack }
+             if (p.nodetype=calln) then
                exclude(p.flags,nf_return_value_used);
                exclude(p.flags,nf_return_value_used);
 
 
              code:=p;
              code:=p;
@@ -1134,8 +1130,8 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.118  2003-10-29 20:01:41  peter
-    * object constructor results are always used
+  Revision 1.119  2003-10-29 20:34:20  peter
+    * move check for unused object constructor result to blocknode
 
 
   Revision 1.117  2003/10/29 15:40:20  peter
   Revision 1.117  2003/10/29 15:40:20  peter
     * support indexing and offset retrieval for locals
     * support indexing and offset retrieval for locals