-
- Downloads
d: Add warning for call expression without side effects
In the last merge of the dmd front-end with upstream (r14-4830), this warning got removed from the semantic passes. Reimplement the warning for the code generation pass instead, where it cannot have an effect on conditional compilation. gcc/d/ChangeLog: * d-codegen.cc (call_side_effect_free_p): New function. * d-tree.h (CALL_EXPR_WARN_IF_UNUSED): New macro. (call_side_effect_free_p): New prototype. * expr.cc (ExprVisitor::visit (CallExp *)): Set CALL_EXPR_WARN_IF_UNUSED on matched call expressions. (ExprVisitor::visit (NewExp *)): Don't dereference the result of an allocation call here. * toir.cc (add_stmt): Emit warning when call expression added to statement list without being used. gcc/testsuite/ChangeLog: * gdc.dg/Wunused_value.d: New test.
Showing
- gcc/d/d-codegen.cc 54 additions, 0 deletionsgcc/d/d-codegen.cc
- gcc/d/d-tree.h 7 additions, 0 deletionsgcc/d/d-tree.h
- gcc/d/expr.cc 12 additions, 1 deletiongcc/d/expr.cc
- gcc/d/toir.cc 32 additions, 0 deletionsgcc/d/toir.cc
- gcc/testsuite/gdc.dg/Wunused_value.d 29 additions, 0 deletionsgcc/testsuite/gdc.dg/Wunused_value.d
Loading
Please register or sign in to comment