- else if
- (!uentry_isStatic (ce)
- && ((sRef_isNewRef (sr))
- || (((sRef_isOnly (sr) || sRef_isFresh (sr)
- || sRef_isKeep (sr) || sRef_isOwned (sr))
- && !sRef_isDead (sr))
- && (!sRef_definitelyNull (sr))
- && (!usymtab_isDefinitelyNull (sr)))))
- {
- bool hasError = TRUE;
-
- DPRINTF (("Checking: %s", sRef_unparseFull (sr)));
-
- /*
- ** If its a scope exit, check if there is an alias.
- ** If so, make it only. If not, there is an error.
- */
-
- if (!isReturn)
- {
- if (transferChecks_canLoseReference (sr, g_currentloc))
- {
- DPRINTF (("Can lose!"));
- hasError = FALSE;
- }
- }
-
- if (hasError)
- {
- if (sRef_hasLastReference (sr))
- {
- sRef ar = sRef_getAliasInfoRef (sr);
-
- if (optgenerror
- (sRef_isFresh (ar) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
- message
- ("Last reference %q to %s storage %qnot %q before %q",
- sRef_unparse (sr),
- alkind_unparse (sRef_getAliasKind (sr)),
- sRef_unparseOpt (ar),
- cstring_makeLiteral (sRef_isKeep (sr)
- ? "transferred" : "released"),
- cstring_makeLiteral (isReturn
- ? "return" : "scope exit")),
- g_currentloc))
- {
- sRef_showRefLost (sr);
- }
- }
- else if (sRef_isNewRef (sr))
- {
- if (optgenerror
- (sRef_isFresh (sr) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
- message
- ("%q %q not released before %q",
- cstring_makeLiteral
- (alkind_isKillRef (sRef_getOrigAliasKind (sr))
- ? "Kill reference parameter" : "New reference"),
- uentry_getName (ce),
- cstring_makeLiteral (isReturn
- ? "return" : "scope exit")),
- g_currentloc))
- {
- sRef_showAliasInfo (sr);
- }
- }
- else
- {
- if (ctype_isRealSU (sRef_getType (sr)))
- {
- transferChecks_structDestroyed (sr, g_currentloc);
- }
- else
- {
- DPRINTF (("Here we are: %s", sRef_unparseFull (sr)));
-
- if (optgenerror
- (sRef_isFresh (sr) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
- message
- ("%s storage %q not %q before %q",
- alkind_capName (sRef_getAliasKind (sr)),
- uentry_getName (ce),
- cstring_makeLiteral (sRef_isKeep (sr)
- ? "transferred" : "released"),
- cstring_makeLiteral (isReturn
- ? "return" : "scope exit")),
- g_currentloc))
- {
- sRef_showAliasInfo (sr);
- DPRINTF (("Storage: %s", sRef_unparseFull (sr)));
- }
- }
- }
- }
- }
- else