Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

exprChecks.c File Reference

#include "lclintMacros.nf"
#include "basic.h"
#include "cgrammar.h"
#include "cgrammar_tokens.h"
#include "aliasChecks.h"
#include "exprChecks.h"

Go to the source code of this file.

Functions

void exprNode_checkStatement (exprNode e)
void exprNode_checkModify (exprNode e, exprNode err)
void exprNode_checkModifyVal (exprNode e, exprNode err)
void exprChecks_checkNullReturn (fileloc loc)
void exprNode_checkReturn (exprNode e)
void exprNode_checkPred (cstring c, exprNode e)
void exprChecks_checkUsedGlobs (globSet decl, globSet used)
void exprNode_checkAllMods (sRefSet mods, uentry ue)
void exprNode_checkMacroBody ( exprNode e)
void exprNode_checkFunctionBody (exprNode body)
void exprNode_checkFunction ( uentry ue, exprNode body)
void exprChecks_checkEmptyMacroBody (void)
void exprNode_checkIterBody ( exprNode body)
void exprNode_checkIterEnd ( exprNode body)
void exprNode_checkCallModifyVal (sRef s, exprNodeList args, exprNode f, exprNode err)
void exprChecks_checkExport (uentry e)


Function Documentation

void exprChecks_checkEmptyMacroBody ( void )
 

Definition at line 899 of file exprChecks.c.

00900 {
00901   uentry hdr;
00902   
00903   if (!(context_inFunctionLike () || context_inMacroConstant ()
00904         || context_inMacroUnknown ()))
00905     {
00906       llcontbug 
00907         (message ("exprNode_checkEmptyMacroBody: not in macro function or constant: %q", 
00908                   context_unparse ()));
00909       return;
00910     }
00911   
00912   hdr = context_getHeader ();
00913   
00914   beginLine ();
00915   
00916   if (uentry_isFunction (hdr))
00917     {
00918       voptgenerror 
00919         (FLG_MACROEMPTY,
00920          message 
00921          ("Macro definition for %q is empty", uentry_getName (hdr)),
00922          g_currentloc);
00923 
00924       usymtab_checkFinalScope (FALSE);
00925     }
00926 
00927   context_exitFunction ();
00928   return;
00929 }

void exprChecks_checkExport ( uentry e )
 

Definition at line 1262 of file exprChecks.c.

01263 {
01264   if (context_checkExport (e))
01265     {
01266       fileloc fl = uentry_whereDeclared (e);
01267       
01268       if (fileloc_isHeader (fl) && !fileloc_isLib (fl) 
01269           && !fileloc_isImport (fl) && !uentry_isStatic (e))
01270         {
01271           if (uentry_isFunction (e) || 
01272               (uentry_isVariable (e) && ctype_isFunction (uentry_getType (e))))
01273             {
01274               voptgenerror 
01275                 (FLG_EXPORTFCN,
01276                  message ("Function exported, but not specified: %q", 
01277                           uentry_getName (e)),
01278                  fl);
01279             }
01280           else if (uentry_isExpandedMacro (e))
01281             {
01282               voptgenerror
01283                 (FLG_EXPORTMACRO,
01284                  message ("Expanded macro exported, but not specified: %q", 
01285                           uentry_getName (e)),
01286                  fl);
01287             }
01288           else if (uentry_isVariable (e) && !uentry_isParam (e)) 
01289             {
01290               voptgenerror 
01291                 (FLG_EXPORTVAR,
01292                  message ("Variable exported, but not specified: %q", 
01293                           uentry_getName (e)),
01294                  fl);
01295             }
01296           else if (uentry_isEitherConstant (e))
01297             {
01298               voptgenerror 
01299                 (FLG_EXPORTCONST,
01300                  message ("Constant exported, but not specified: %q", 
01301                           uentry_getName (e)),
01302                  fl);
01303             }
01304           else if (uentry_isIter (e) || uentry_isEndIter (e))
01305             {
01306               voptgenerror 
01307                 (FLG_EXPORTITER,
01308                  message ("Iterator exported, but not specified: %q", 
01309                           uentry_getName (e)),
01310                  fl);
01311             }
01312 
01313           else if (uentry_isDatatype (e))
01314             {
01315               ; /* error already reported */
01316             }
01317           else
01318             {
01319               BADEXIT;
01320             }
01321         }
01322     }
01323 }

void exprChecks_checkNullReturn ( fileloc loc )
 

Definition at line 349 of file exprChecks.c.

Referenced by exprNode_nullReturn().

00350 {
00351   if (!context_inRealFunction ())
00352     {
00353       /*
00354       llmsg ("exprChecks_checkNullReturnExpr: not in function context");
00355       */
00356       return;
00357     }
00358   else
00359     {
00360       if (ctype_isFunction (context_currentFunctionType ()))
00361         {
00362           ctype tr = ctype_returnValue (context_currentFunctionType ());
00363 
00364           if (!ctype_isFirstVoid (tr))
00365             {
00366               if (ctype_isUnknown (tr))
00367                 {
00368                   voptgenerror
00369                     (FLG_CONTROL,
00370                      cstring_makeLiteral ("Empty return in function declared to implicitly return int"),
00371                      loc);
00372                 }
00373               else
00374                 {
00375                   voptgenerror (FLG_CONTROL,
00376                                 message ("Empty return in function declared to return %t", tr),
00377                                 loc);
00378                 }
00379             }
00380         }
00381     }
00382 }

void exprChecks_checkUsedGlobs ( globSet decl,
globSet used )
 

Definition at line 469 of file exprChecks.c.

Referenced by context_exitFunction().

00470 {
00471   fileloc fl = uentry_whereSpecified (context_getHeader ());
00472 
00473   if (fileloc_isUndefined (fl))
00474     {
00475       fl = uentry_whereDeclared (context_getHeader ());
00476     }
00477 
00478   globSet_allElements (decl, el)
00479     {
00480       if (!globSet_member (used, el))
00481         {
00482           if (sRef_isSpecInternalState (el)
00483               || sRef_isNothing (el))
00484             {
00485               ;
00486             }
00487           else
00488             {
00489               cstring sname = sRef_unparse (el);
00490               
00491               if (fileloc_isLib (fl))
00492                 {
00493                   voptgenerror (FLG_USEALLGLOBS,
00494                                 message ("Global %s listed (%q) but not used", 
00495                                          sname, fileloc_unparse (fl)),
00496                                 g_currentloc);
00497                 }               
00498               else
00499                 {
00500                   voptgenerror (FLG_USEALLGLOBS,
00501                                 message ("Global %s listed but not used", sname),
00502                                 fl);
00503                 }
00504 
00505               cstring_free (sname);
00506             }
00507         }
00508     } end_globSet_allElements;
00509 }

void exprNode_checkAllMods ( sRefSet mods,
uentry ue )
 

Definition at line 512 of file exprChecks.c.

Referenced by context_exitFunction().

00513 {
00514   bool realParams = FALSE;
00515   uentry le = context_getHeader ();
00516   fileloc fl = uentry_whereSpecified (le);
00517   uentryList specParamNames = uentryList_undefined;
00518   uentryList paramNames = context_getParams ();
00519 
00520   if (uentry_isFunction (le))
00521     {
00522       specParamNames = uentry_getParams (le);  
00523 
00524       if (uentryList_isUndefined (specParamNames))
00525         {
00526           ; /* unknown params */
00527         }
00528       else if (uentryList_size (paramNames) != uentryList_size (specParamNames))
00529         {
00530           llbug
00531             (message ("exprNode_checkAllMods: parameter lists have different sizes: "
00532                       "%q (%d) / %q (%d)",
00533                       uentryList_unparse (paramNames),
00534                       uentryList_size (paramNames),
00535                       uentryList_unparse (specParamNames),
00536                       uentryList_size (specParamNames)));
00537         }
00538       else if (uentryList_size (paramNames) > 0 
00539                && !uentry_hasRealName (uentryList_getN (specParamNames, 0)))
00540         {
00541           /* loaded from a library */
00542         }
00543       else
00544         {
00545           realParams = TRUE;
00546         }
00547     }
00548 
00549   sRefSet_allElements (mods, sr)
00550     {
00551       if (sRef_isNothing (sr) || sRef_isSpecState (sr))
00552         {
00553           ; /* should report on anything? */
00554         }
00555       else if (sRef_isInternalState (sr))
00556         {
00557           if (!sRef_isModified (sr))
00558             {
00559               if (sRefSet_hasStatic (mods))
00560                 {
00561                   ; /* okay */
00562                 }
00563               else
00564                 {
00565                   if (optgenerror 
00566                       (FLG_MUSTMOD,
00567                        message
00568                        ("Function %s specified to modify internal state "
00569                         "but no internal state is modified", 
00570                         uentry_rawName (ue)),
00571                        uentry_whereLast (ue)))
00572                     {
00573                       uentry_showWhereSpecified (le);
00574                     }
00575                 }
00576             }
00577         }
00578       else 
00579         {
00580           if (!sRef_isModified (sr))
00581             {
00582               cstring sname = realParams ? sRef_unparse (sr) : sRef_unparse (sr);
00583               
00584               if (fileloc_isLib (fl) && !realParams)
00585                 {
00586                   voptgenerror 
00587                     (FLG_MUSTMOD,
00588                      message ("Suspect object listed (%q) in modifies "
00589                               "clause of %s not modified: %s", 
00590                               fileloc_unparse (fl),
00591                               uentry_rawName (ue),
00592                               sname),
00593                      uentry_whereLast (ue));
00594                 }               
00595               else
00596                 {
00597                   if (optgenerror 
00598                       (FLG_MUSTMOD,
00599                        message ("Suspect object listed in modifies of %s "
00600                                 "not modified: %s", 
00601                                 uentry_rawName (ue),
00602                                 sname),
00603                        uentry_whereLast (ue)))
00604                     {
00605                       uentry_showWhereSpecified (le);
00606                     }
00607                 }
00608               cstring_free (sname);
00609             }
00610         }
00611     } end_sRefSet_allElements;
00612 }

void exprNode_checkCallModifyVal ( sRef s,
exprNodeList args,
exprNode f,
exprNode err )
 

Definition at line 1255 of file exprChecks.c.

01256 {
01257   s = sRef_fixBaseParam (s, args);
01258   sRef_aliasCheckPred (checkCallModifyAux, NULL, s, f, err);
01259 }

void exprNode_checkFunction ( uentry ue,
exprNode body )
 

Definition at line 894 of file exprChecks.c.

00895 {
00896   exprNode_free (body);
00897   }

void exprNode_checkFunctionBody ( exprNode body )
 

Definition at line 852 of file exprChecks.c.

00853 {
00854   if (!exprNode_isError (body))
00855     {
00856       bool noret = context_getFlag (FLG_NORETURN);
00857       bool checkret = exprNode_mustEscape (body);
00858 
00859       if (!checkret 
00860           && noret 
00861           && !exprNode_errorEscape (body)
00862           && context_inRealFunction ()
00863           && ctype_isFunction (context_currentFunctionType ()))
00864         {
00865           ctype tr = ctype_returnValue (context_currentFunctionType ());
00866           
00867           if (!ctype_isFirstVoid (tr)) 
00868             {
00869               if (ctype_isUnknown (tr))
00870                 {
00871                   voptgenerror 
00872                     (FLG_NORETURN,
00873                      cstring_makeLiteral ("Path with no return in function declared to implicity return int"), 
00874                      g_currentloc);
00875                 }
00876               else
00877                 {
00878                   voptgenerror 
00879                     (FLG_NORETURN,
00880                      message ("Path with no return in function declared to return %t", 
00881                               tr),
00882                      g_currentloc);
00883                 }
00884             }
00885         }
00886       
00887       if (!checkret)
00888         {
00889           context_returnFunction ();
00890         }
00891     }
00892 }

void exprNode_checkIterBody ( exprNode body )
 

Definition at line 931 of file exprChecks.c.

00932 {
00933   context_exitAllClauses ();
00934 
00935   context_exitFunction ();
00936   exprNode_free (body);
00937 }

void exprNode_checkIterEnd ( exprNode body )
 

Definition at line 939 of file exprChecks.c.

00940 {
00941   context_exitAllClauses ();
00942   context_exitFunction ();
00943   exprNode_free (body);
00944 }

void exprNode_checkMacroBody ( exprNode e )
 

Definition at line 614 of file exprChecks.c.

00615 {
00616   if (!exprNode_isError (e))
00617     {
00618       uentry hdr;
00619 
00620       if (!(context_inFunctionLike () || context_inMacroConstant ()
00621             || context_inMacroUnknown ()))
00622         {
00623           llcontbug 
00624             (message 
00625              ("exprNode_checkMacroBody: not in macro function or constant: %q", 
00626               context_unparse ()));
00627           exprNode_free (e);
00628           return;
00629         }
00630 
00631       hdr = context_getHeader ();
00632       
00633       if (e->kind == XPR_STMTLIST || e->kind == XPR_BODY)
00634         {
00635           voptgenerror 
00636             (FLG_MACROSTMT,
00637              message 
00638              ("Macro %q definition is statement list (recommend "
00639               "do { ... } while (0) constuction to ensure multiple "
00640               "statement macro is syntactic function)",
00641               uentry_getName (hdr)),
00642              fileloc_isDefined (e->loc) ? e->loc : g_currentloc);
00643         }
00644       
00645       if (context_inMacroConstant ())
00646         {
00647           ctype t = uentry_getType (hdr);
00648 
00649           uentry_setDefined (hdr, e->loc);
00650           
00651           if (!(exprNode_matchType (t, e)))
00652             {
00653               cstring uname = uentry_getName (hdr);
00654 
00655               if (cstring_equal (uname, context_getTrueName ())
00656                   || cstring_equal (uname, context_getFalseName ()))
00657                 {
00658                   /* 
00659                   ** We need to do something special to allow FALSE and TRUE
00660                   ** to be defined without reporting errors.  This is a tad
00661                   ** bogus, but otherwise lots of things would break.
00662                   */
00663 
00664 
00665                   llassert (ctype_isManifestBool (t));
00666                   /* Should also check type of e is a reasonable (?) bool type. */
00667                 }
00668               else 
00669                 {
00670                   if (optgenerror 
00671                       (FLG_INCONDEFS,
00672                        message
00673                        ("Constant %q specified as %s, but defined as %s: %s",
00674                         uentry_getName (hdr),
00675                         ctype_unparse (t),
00676                         ctype_unparse (e->typ),
00677                         exprNode_unparse (e)),
00678                        e->loc))
00679                     {
00680                       uentry_showWhereSpecified (hdr);
00681                     }
00682                 }
00683 
00684               cstring_free (uname);
00685             }
00686           else
00687             {
00688               if (context_maybeSet (FLG_NULLSTATE)
00689                   && ctype_isUA(t) 
00690                   && ctype_isRealPointer (t)
00691                   && exprNode_isNullValue (e))
00692                 {
00693                   uentry ue = usymtab_getTypeEntry (ctype_typeId (t));
00694                   sRef   sr = uentry_getSref (ue);
00695                   
00696                   if (!sRef_possiblyNull (sr))
00697                     {
00698                       vgenhinterror 
00699                         (FLG_NULLSTATE,
00700                          message ("Constant %q of non-null type %s defined "
00701                                   "as null: %s",
00702                                   uentry_getName (hdr), ctype_unparse (t),
00703                                   exprNode_unparse (e)),
00704                          message ("If %s can be null, add a /*@null@*/ "
00705                                   "qualifer to its typedef.",
00706                                   ctype_unparse (t)),
00707                          e->loc);
00708                     }
00709                   
00710                   uentry_mergeConstantValue (hdr, e->val);
00711                   e->val = multiVal_undefined;
00712                 }
00713             }
00714         }
00715       else if (context_inMacroFunction () || context_inMacroUnknown ())
00716         {
00717           ctype rettype = context_getRetType ();
00718 
00719           if (context_isMacroMissingParams ())
00720             {
00721               llassert (context_inMacroFunction ());
00722 
00723               /*
00724               ** # define newname oldname
00725               **
00726               ** newname is a function
00727               ** specification of oldname should match
00728               ** specification of newname.
00729               */
00730 
00731               if (!ctype_isFunction (e->typ))
00732                 {
00733                   voptgenerror 
00734                     (FLG_INCONDEFS,
00735                      message ("Function %s defined by unparameterized "
00736                               "macro not corresponding to function",
00737                               context_inFunctionName ()),
00738                      e->loc);
00739                 }
00740               else
00741                 {
00742                   uentry ue = exprNode_getUentry (e);
00743 
00744                   if (uentry_isValid (ue))
00745                     {
00746                       /*
00747                       ** Okay, for now --- should check for consistency
00748                       */
00749                       /*
00750                       ** uentry oldue = usymtab_lookup (cfname);
00751                       */
00752 
00753                       /* check var conformance here! */
00754                     }
00755                   else
00756                     {
00757                       voptgenerror
00758                         (FLG_INCONDEFS,
00759                          message ("Function %s defined by unparameterized "
00760                                   "macro not corresponding to function",
00761                                   context_inFunctionName ()),
00762                          e->loc);
00763                     }
00764                   
00765                   e->typ = ctype_returnValue (e->typ);
00766                   rettype = e->typ; /* avoid aditional errors */
00767                 }
00768             }
00769 
00770           if (ctype_isVoid (rettype) || ctype_isUnknown (rettype))
00771             {
00772              ; /* don't complain when void macros have values */
00773             }       
00774           else if (!exprNode_matchType (rettype, e))
00775             {
00776               if (optgenerror 
00777                   (FLG_INCONDEFS,
00778                    message ("Function %q specified to return %s, "
00779                             "implemented as macro having type %s: %s",
00780                             uentry_getName (hdr),
00781                             ctype_unparse (rettype), ctype_unparse (e->typ),
00782                             exprNode_unparse (e)),
00783                    e->loc))
00784                 {
00785                   uentry_showWhereSpecified (hdr);
00786                 }
00787             }
00788           else
00789             {
00790               switch (e->kind)
00791                 {
00792                   /* these expressions have values: */
00793                 case XPR_PARENS: case XPR_ASSIGN: 
00794                 case XPR_EMPTY: case XPR_VAR:
00795                 case XPR_OP: case XPR_POSTOP: 
00796                 case XPR_PREOP: case XPR_CALL: 
00797                 case XPR_SIZEOFT: case XPR_SIZEOF: 
00798                 case XPR_ALIGNOFT: case XPR_ALIGNOF: 
00799                 case XPR_CAST: case XPR_FETCH: 
00800                 case XPR_COMMA: case XPR_COND: 
00801                 case XPR_ARROW: case XPR_CONST: 
00802                 case XPR_STRINGLITERAL: case XPR_NUMLIT:
00803                 case XPR_FACCESS: case XPR_OFFSETOF:
00804 
00805                   checkReturnTransfer (e, hdr);
00806                   break;
00807 
00808                   /* these expressions don't */
00809                 case XPR_LABEL:
00810                 case XPR_VAARG: case XPR_ITER: 
00811                 case XPR_FOR: case XPR_FORPRED:
00812                 case XPR_GOTO: case XPR_CONTINUE: 
00813                 case XPR_BREAK: case XPR_RETURN:
00814                 case XPR_NULLRETURN: case XPR_IF: 
00815                 case XPR_IFELSE: case XPR_DOWHILE:
00816                 case XPR_WHILE: case XPR_STMT: 
00817                 case XPR_STMTLIST: case XPR_SWITCH:
00818                 case XPR_INIT: case XPR_BODY: 
00819                 case XPR_NODE: case XPR_ITERCALL:
00820                 case XPR_TOK: case XPR_CASE: 
00821                 case XPR_FTCASE: case XPR_FTDEFAULT:
00822                 case XPR_DEFAULT: case XPR_WHILEPRED:
00823                 case XPR_BLOCK: case XPR_INITBLOCK:
00824                   if (optgenerror 
00825                       (FLG_INCONDEFS,
00826                        message ("Function %q specified to return %s, "
00827                                 "implemented as macro with no result: %s",
00828                                 uentry_getName (hdr),
00829                                 ctype_unparse (rettype), 
00830                                 exprNode_unparse (e)),
00831                        e->loc))
00832                     {
00833                       uentry_showWhereSpecified (hdr);
00834                     }
00835                 }
00836             }
00837 
00838           usymtab_checkFinalScope (FALSE);
00839         }
00840       else
00841         {
00842           llbug (message ("exprNode_checkMacroBody: not in macro function: %q", context_unparse ()));
00843         }
00844 
00845       exprNode_free (e);
00846     }
00847 
00848   context_exitFunction ();
00849   return;
00850 }

void exprNode_checkModify ( exprNode e,
exprNode err )
 

Definition at line 323 of file exprChecks.c.

Referenced by exprNode_postOp(), and exprNode_preOp().

00324 {
00325   llassert (exprNode_isDefined (e));
00326 
00327   DPRINTF (("Check modify: %s", exprNode_unparse (e)));
00328 
00329   if (sRef_isValid (e->sref))
00330     {
00331       sRef_aliasCheckPred (checkModifyAux, sRef_isReference, e->sref, e, err);
00332     }
00333 }

void exprNode_checkModifyVal ( exprNode e,
exprNode err )
 

Definition at line 336 of file exprChecks.c.

00337 {
00338   llassert (exprNode_isDefined (e));
00339   
00340   DPRINTF (("Check modify val: %s", exprNode_unparse (e)));
00341 
00342   if (sRef_isValid (e->sref))
00343     {
00344       sRef_aliasCheckPred (checkModifyValAux, sRef_isReference, e->sref, e, err);
00345     }
00346 }

void exprNode_checkPred ( cstring c,
exprNode e )
 

Definition at line 419 of file exprChecks.c.

Referenced by exprNode_cond(), exprNode_doWhile(), exprNode_forPred(), exprNode_if(), exprNode_ifelse(), and exprNode_whilePred().

00420 {
00421   ctype ct;
00422 
00423   if (exprNode_isError (e))
00424     return;
00425 
00426   ct = exprNode_getType (e);
00427 
00428   if (exprNode_isAssign (e))
00429     {
00430       voptgenerror 
00431         (FLG_PREDASSIGN,
00432          message ("Test expression for %s is assignment expression: %s", 
00433                   c, exprNode_unparse (e)),
00434          e->loc);
00435     }
00436 
00437   if (ctype_isRealBool (ct))
00438     {
00439      ;
00440     }
00441   else if (ctype_isRealPointer (ct))
00442     {
00443       voptgenerror
00444         (FLG_PREDBOOLPTR,
00445          message ("Test expression for %s not %s, type %t: %s", c, 
00446                   context_printBoolName (), 
00447                   ct, exprNode_unparse (e)),
00448          e->loc);
00449     }
00450   else if (ctype_isRealInt (ct))
00451     {
00452       voptgenerror 
00453         (FLG_PREDBOOLINT,
00454          message ("Test expression for %s not %s, type %t: %s", c, 
00455                   context_printBoolName (), ct, exprNode_unparse (e)),
00456          e->loc);
00457     }
00458   else
00459     {
00460       voptgenerror 
00461         (FLG_PREDBOOLOTHERS,
00462          message ("Test expression for %s not %s, type %t: %s", c, 
00463                   context_printBoolName (), ct, exprNode_unparse (e)),
00464          e->loc);
00465     }
00466 }

void exprNode_checkReturn ( exprNode e )
 

Definition at line 385 of file exprChecks.c.

Referenced by exprNode_return().

00386 {
00387   if (!exprNode_isError (e))
00388     {
00389       if (!context_inRealFunction ())
00390         {
00391           if (context_inMacro ())
00392             {
00393               llerror (FLG_CONTROL,
00394                        message ("Macro %s uses return (not functional)",
00395                                 context_inFunctionName ()));
00396             }
00397           else
00398             {
00399               /*
00400                 llbuglit ("exprNode_checkReturn: not in function context");
00401                 */
00402             }
00403         }
00404       else
00405         {
00406           if (ctype_isFunction (context_currentFunctionType ()))
00407             {
00408               checkSafeReturnExpr (e);
00409             }
00410           else
00411             {
00412               ;
00413             }
00414         }
00415     }
00416 }

void exprNode_checkStatement ( exprNode e )
 

Definition at line 56 of file exprChecks.c.

Referenced by exprNode_statement().

00057 {
00058   bool hasError = FALSE;
00059 
00060   if (!exprNode_isError (e))
00061     {
00062       exprKind ek = e->kind;
00063 
00064       if (ek == XPR_CALL && !(ctype_isRealVoid (e->typ)))
00065         { 
00066           if (ctype_isKnown (e->typ))
00067             {
00068               if (ctype_isManifestBool (ctype_realishType (e->typ)))
00069                 {
00070                   hasError = optgenerror 
00071                     (FLG_RETVALBOOL,
00072                      message ("Return value (type %t) ignored: %s",
00073                               e->typ,
00074                               exprNode_unparseFirst (e)),
00075                      e->loc);
00076                 }
00077               else if (ctype_isDirectInt (e->typ))
00078                 {
00079                   hasError = optgenerror 
00080                     (FLG_RETVALINT,
00081                      message ("Return value (type %t) ignored: %s",
00082                               e->typ,
00083                               exprNode_unparseFirst (e)),
00084                      e->loc);
00085                 }
00086               else
00087                 {
00088                   hasError = optgenerror 
00089                     (FLG_RETVALOTHER,
00090                      message ("Return value (type %t) ignored: %s",
00091                               e->typ,
00092                               exprNode_unparseFirst (e)),
00093                      e->loc);
00094                 }
00095             }
00096         }
00097 
00098       if (!hasError && !(exprNode_mayEscape (e))
00099           && !(e->canBreak)) /* control changes are effects too! */
00100         {
00101           if (sRefSet_hasRealElement (e->sets)
00102               || sRefSet_hasRealElement (e->msets))
00103             {
00104               ; /* okay */
00105             }
00106           else
00107             {
00108               if (sRefSet_isEmpty (e->sets) && sRefSet_isEmpty (e->msets))
00109                 {
00110                   voptgenerror
00111                     (FLG_NOEFFECT,
00112                      message ("Statement has no effect: %s",
00113                               exprNode_unparseFirst (e)),
00114                      e->loc);
00115                 }
00116               else
00117                 {
00118                   if (context_maybeSet (FLG_NOEFFECTUNCON))
00119                     {
00120                       if (sRefSet_hasUnconstrained (e->sets))
00121                         {
00122                           voptgenerror
00123                             (FLG_NOEFFECTUNCON,
00124                              message ("Statement has no effect (possible "
00125                                       "undected modification through "
00126                                       "call to %q): %s",
00127                                       sRefSet_unparseUnconstrained (e->sets),
00128                                       exprNode_unparseFirst (e)),
00129                              e->loc);
00130                         }
00131                       else if (sRefSet_hasUnconstrained (e->msets))
00132                         {
00133                           voptgenerror
00134                             (FLG_NOEFFECTUNCON,
00135                              message ("Statement has no effect (possible "
00136                                       "undected modification through "
00137                                       "call to %q): %s",
00138                                       sRefSet_unparseUnconstrained (e->msets),
00139                                       exprNode_unparseFirst (e)),
00140                              e->loc);
00141                         }
00142                       else
00143                         {
00144                           ; /* statement has unknown modification */
00145                         }
00146                     }
00147                 }
00148             }
00149         }
00150     }
00151 }


Generated at Fri Nov 3 18:57:55 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000