DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls
Timon Gehr
timon.gehr at gmx.ch
Thu Feb 27 15:52:08 PST 2014
On 02/28/2014 12:38 AM, "Nordlöw" wrote:
> Does anybody know where in the DMD source I can figure out if the return
> value of a function call is used or not?
I'm not familiar with the DMD source code, but a good way to proceed is
usually to grep for existing error messages that are somehow related. In
this case, DMD already complains about some cases of unused values:
$ grep "no effect" *.c
declaration.c: error("storage class 'auto' has no effect if type
is not inferred, did you mean 'scope'?");
expression.c: e = new CastExp(loc, e, Type::tvoid); //
avoid "has no effect" error
mtype.c: // substitution has no effect on function pointer type.
sideeffect.c: * Don't complain about an expression
with no effect if it was cast to void
sideeffect.c: /* Don't complain about calling functions
with no effect,
sideeffect.c: error("%s has no effect", toChars());
sideeffect.c: error("%s has no effect in expression (%s)",
This leads directly to sideeffect.c: Expression::discardValue(), which
seems to be the place where you want to insert your detection code.
More information about the Digitalmars-d-learn
mailing list