diff options
| author | bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-17 09:34:21 +0000 |
|---|---|---|
| committer | bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-17 09:34:21 +0000 |
| commit | 481c6ce6ce166320db23dc2d8121e56e0e85e90e (patch) | |
| tree | 9a9bf64517120736c23b7a0ecdb4c40f71e7b674 /gcc/c-typeck.c | |
| parent | af7db8cb22256d2ba4039fe9ef231702f4bb92c2 (diff) | |
| download | ppe42-gcc-481c6ce6ce166320db23dc2d8121e56e0e85e90e.tar.gz ppe42-gcc-481c6ce6ce166320db23dc2d8121e56e0e85e90e.zip | |
Improved sequence point warnings
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36901 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
| -rw-r--r-- | gcc/c-typeck.c | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index d40aee19f66..0d2209e501a 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -61,7 +61,6 @@ static tree pointer_diff PARAMS ((tree, tree)); static tree unary_complex_lvalue PARAMS ((enum tree_code, tree)); static void pedantic_lvalue_warning PARAMS ((enum tree_code)); static tree internal_build_compound_expr PARAMS ((tree, int)); -static void check_modify_expr PARAMS ((tree, tree)); static tree convert_for_assignment PARAMS ((tree, tree, const char *, tree, tree, int)); static void warn_for_assignment PARAMS ((const char *, const char *, @@ -3816,132 +3815,6 @@ build_c_cast (type, expr) return value; } -/* Recursive check for expressions that break the sequence point rules - and so have undefined semantics (e.g. n = n++). FIXME: if walk_tree - gets moved out of the C++ front end, this should probably be moved - to code shared between the front ends and use walk_tree. */ -static void -check_modify_expr (lhs, rhs) - tree lhs, rhs; -{ - tree identifier_name; /* A VAR_DECL name on the LHS that could - be the same as one on the RHS. */ - identifier_name = NULL_TREE; - - if ((lhs == NULL_TREE) || (rhs == NULL_TREE)) - return; - - switch (TREE_CODE (rhs)) - { - case ERROR_MARK: - return; - case VAR_DECL: - case PARM_DECL: - identifier_name = DECL_NAME (rhs); - break; - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - { - tree var_decl = TREE_OPERAND (rhs, 0); - if (TREE_CODE (var_decl) == VAR_DECL - || TREE_CODE (var_decl) == PARM_DECL) - identifier_name = DECL_NAME (var_decl); - } - break; - case TREE_LIST: - { - tree parm = TREE_CHAIN (rhs); - /* Now scan all the list, e.g. indices of multi dimensional array. */ - while (parm) - { - check_modify_expr (lhs, TREE_VALUE (parm)); - parm = TREE_CHAIN (parm); - } - } - return; - case NOP_EXPR: - case CONVERT_EXPR: - case NON_LVALUE_EXPR: - check_modify_expr (lhs, TREE_OPERAND (rhs, 0)); - return; - case MODIFY_EXPR: - /* First check for form a = b = a++ by checking RHS. */ - check_modify_expr (lhs, TREE_OPERAND (rhs, 1)); - /* Then check for a = (a = 1) + 2 and a = b[a++] = c. */ - if (TREE_CODE (TREE_OPERAND (rhs, 0)) == VAR_DECL - || TREE_CODE (TREE_OPERAND (rhs, 0)) == PARM_DECL) - { - identifier_name = DECL_NAME (TREE_OPERAND (rhs, 0)); - break; - } - else - { - check_modify_expr (lhs, TREE_OPERAND (rhs, 0)); - return; - } - default: - /* We don't know what to do... pray check_modify_expr removes - loops in the tree. */ - switch (TREE_CODE_CLASS (TREE_CODE (rhs))) - { - case 'r': - case '<': - case '2': - case 'b': - case '1': - case 'e': - case 's': - case 'x': - { - int lp; - int max = first_rtl_op (TREE_CODE (rhs)); - for (lp = 0; lp < max; lp++) - check_modify_expr (lhs, TREE_OPERAND (rhs, lp)); - return; - } - default: - return; - } - break; - } - if (identifier_name != NULL_TREE) - { - switch (TREE_CODE (lhs)) - { - case ERROR_MARK: - return; - /* Perhaps this variable was incremented on the RHS. */ - case VAR_DECL: - case PARM_DECL: - if (TREE_CODE (rhs) != VAR_DECL && TREE_CODE (rhs) != PARM_DECL) - if (DECL_NAME (lhs) == identifier_name) - warning ("operation on `%s' may be undefined", - IDENTIFIER_POINTER (DECL_NAME (lhs))); - break; - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - { - tree var_decl = TREE_OPERAND (lhs, 0); - if (TREE_CODE (var_decl) == VAR_DECL - || TREE_CODE (var_decl) == PARM_DECL) - if (identifier_name == DECL_NAME (var_decl)) - warning ("operation on `%s' may be undefined", - IDENTIFIER_POINTER (DECL_NAME (var_decl))); - } - break; - default: - /* To save duplicating tree traversal code swap args, and recurse. */ - check_modify_expr (rhs, lhs); - break; - } - } -} - - /* Build an assignment expression of lvalue LHS from value RHS. MODIFYCODE is the code for a binary operator that we use to combine the old value of LHS with RHS to get the new value. @@ -4096,9 +3969,6 @@ build_modify_expr (lhs, modifycode, rhs) if (TREE_CODE (newrhs) == ERROR_MARK) return error_mark_node; - if (warn_sequence_point) - check_modify_expr (lhs, rhs); - /* Scan operands */ result = build (MODIFY_EXPR, lhstype, lhs, newrhs); |

