aboutsummaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2012-04-10 16:33:47 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2012-04-10 16:33:47 +0000
commitfd4116f49cdf081949633ba8f474d7b160860701 (patch)
treea263fcd5e0513ef5acd316e056419a84c1daad7d /gcc/stmt.c
parent408baa0b1643c3fcab1ac6a7c078bd37675ab017 (diff)
downloadgcc-fd4116f49cdf081949633ba8f474d7b160860701.zip
gcc-fd4116f49cdf081949633ba8f474d7b160860701.tar.gz
gcc-fd4116f49cdf081949633ba8f474d7b160860701.tar.bz2
c-common.c (warn_if_unused_value): Move definition to here.
2012-04-10 Manuel López-Ibáñez <manu@gcc.gnu.org> * c-family/c-common.c (warn_if_unused_value): Move definition to here. * tree.h (warn_if_unused_value): Move declaration from here. * c-family/c-common.h (warn_if_unused_value): Move declaration to here. * cp/cvt.c (convert_to_void): Update comment. * stmt.c (warn_if_unused_value): Move definition from here. From-SVN: r186287
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c96
1 files changed, 0 insertions, 96 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 93d643a..0589bfd 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1472,102 +1472,6 @@ expand_expr_stmt (tree exp)
free_temp_slots ();
}
-/* Warn if EXP contains any computations whose results are not used.
- Return 1 if a warning is printed; 0 otherwise. LOCUS is the
- (potential) location of the expression. */
-
-int
-warn_if_unused_value (const_tree exp, location_t locus)
-{
- restart:
- if (TREE_USED (exp) || TREE_NO_WARNING (exp))
- return 0;
-
- /* Don't warn about void constructs. This includes casting to void,
- void function calls, and statement expressions with a final cast
- to void. */
- if (VOID_TYPE_P (TREE_TYPE (exp)))
- return 0;
-
- if (EXPR_HAS_LOCATION (exp))
- locus = EXPR_LOCATION (exp);
-
- switch (TREE_CODE (exp))
- {
- case PREINCREMENT_EXPR:
- case POSTINCREMENT_EXPR:
- case PREDECREMENT_EXPR:
- case POSTDECREMENT_EXPR:
- case MODIFY_EXPR:
- case INIT_EXPR:
- case TARGET_EXPR:
- case CALL_EXPR:
- case TRY_CATCH_EXPR:
- case WITH_CLEANUP_EXPR:
- case EXIT_EXPR:
- case VA_ARG_EXPR:
- return 0;
-
- case BIND_EXPR:
- /* For a binding, warn if no side effect within it. */
- exp = BIND_EXPR_BODY (exp);
- goto restart;
-
- case SAVE_EXPR:
- case NON_LVALUE_EXPR:
- exp = TREE_OPERAND (exp, 0);
- goto restart;
-
- case TRUTH_ORIF_EXPR:
- case TRUTH_ANDIF_EXPR:
- /* In && or ||, warn if 2nd operand has no side effect. */
- exp = TREE_OPERAND (exp, 1);
- goto restart;
-
- case COMPOUND_EXPR:
- if (warn_if_unused_value (TREE_OPERAND (exp, 0), locus))
- return 1;
- /* Let people do `(foo (), 0)' without a warning. */
- if (TREE_CONSTANT (TREE_OPERAND (exp, 1)))
- return 0;
- exp = TREE_OPERAND (exp, 1);
- goto restart;
-
- case COND_EXPR:
- /* If this is an expression with side effects, don't warn; this
- case commonly appears in macro expansions. */
- if (TREE_SIDE_EFFECTS (exp))
- return 0;
- goto warn;
-
- case INDIRECT_REF:
- /* Don't warn about automatic dereferencing of references, since
- the user cannot control it. */
- if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == REFERENCE_TYPE)
- {
- exp = TREE_OPERAND (exp, 0);
- goto restart;
- }
- /* Fall through. */
-
- default:
- /* Referencing a volatile value is a side effect, so don't warn. */
- if ((DECL_P (exp) || REFERENCE_CLASS_P (exp))
- && TREE_THIS_VOLATILE (exp))
- return 0;
-
- /* If this is an expression which has no operands, there is no value
- to be unused. There are no such language-independent codes,
- but front ends may define such. */
- if (EXPRESSION_CLASS_P (exp) && TREE_OPERAND_LENGTH (exp) == 0)
- return 0;
-
- warn:
- warning_at (locus, OPT_Wunused_value, "value computed is not used");
- return 1;
- }
-}
-
/* Generate RTL to return from the current function, with no value.
(That is, we do not do anything about returning any value.) */