sval: move cast_rl() into parse_value_ranges_type()
[smatch.git] / check_no_effect.c
bloba1e4330123100a04772beeb2021d754db27c66f4
1 /*
2 * sparse/check_no_effect.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
12 static int my_id;
14 static void match_stmt(struct statement *stmt)
16 struct expression *expr;
18 if (stmt->type != STMT_EXPRESSION)
19 return;
20 expr = stmt->expression;
21 if (!expr)
22 return;
23 switch(expr->type) {
24 case EXPR_PREOP:
25 if (expr->op == '!')
26 break;
27 if (expr->op == '~')
28 break;
29 case EXPR_POSTOP:
30 case EXPR_STATEMENT:
31 case EXPR_ASSIGNMENT:
32 case EXPR_CALL:
33 case EXPR_CONDITIONAL:
34 case EXPR_SELECT:
35 case EXPR_CAST:
36 case EXPR_FORCE_CAST:
37 case EXPR_COMMA:
38 return;
40 if (in_expression_statement())
41 return;
42 sm_msg("warn: statement has no effect %d", expr->type);
45 void check_no_effect(int id)
47 my_id = id;
48 add_hook(&match_stmt, STMT_HOOK);