diff options
| author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-23 01:35:06 +0000 |
|---|---|---|
| committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-23 01:35:06 +0000 |
| commit | 45a78cc0d27599fccb48470d7f89b113b7fcb446 (patch) | |
| tree | 2dc0be928c289ceb6e2df4ae5cf04396eb70721e /gcc/c-typeck.c | |
| parent | b96dc1214cf672f219471ff29ee90c6c109393c5 (diff) | |
| download | ppe42-gcc-45a78cc0d27599fccb48470d7f89b113b7fcb446.tar.gz ppe42-gcc-45a78cc0d27599fccb48470d7f89b113b7fcb446.zip | |
* c-common.c (c_common_truthvalue_conversion): Adjust comment.
Call c_common_truthvalue_conversion rather than
lang_hooks.truthvalue_conversion.
* c-convert.c (convert): Call c_objc_common_truthvalue_conversion.
* c-objc-common.c (c_objc_common_truthvalue_conversion): Move to
c-typeck.c.
* c-objc-common.h (LANG_HOOKS_TRUTHVALUE_CONVERSION): Change to
c_common_truthvalue_conversion.
* c-parser.c (c_parser_paren_condition, c_parser_for_statement,
c_parser_conditional_expression, c_parser_binary_expression): Call
c_objc_common_truthvalue_conversion.
* c-typeck.c (build_unary_op): Call
c_objc_common_truthvalue_conversion.
(build_conditional_expr): Do not call
lang_hooks.truthvalue_conversion.
(build_binary_op): Call c_common_truthvalue_conversion.
(c_objc_common_truthvalue_conversion): Moved from
c-objc-common.c. Call default_function_array_conversion instead
of default_conversion.
objc:
* objc-act.c (next_sjlj_build_enter_and_setjmp,
next_sjlj_build_catch_list, next_sjlj_build_try_catch_finally):
Call c_common_truthvalue_conversion.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96917 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
| -rw-r--r-- | gcc/c-typeck.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index a89c87a3601..9ddafe10c5d 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2561,6 +2561,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag) break; case TRUTH_NOT_EXPR: + /* ??? Why do most validation here but that for non-lvalue arrays + in c_objc_common_truthvalue_conversion? */ if (typecode != INTEGER_TYPE && typecode != REAL_TYPE && typecode != POINTER_TYPE && typecode != COMPLEX_TYPE @@ -2570,7 +2572,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag) error ("wrong type argument to unary exclamation mark"); return error_mark_node; } - arg = lang_hooks.truthvalue_conversion (arg); + arg = c_objc_common_truthvalue_conversion (arg); return invert_truthvalue (arg); case NOP_EXPR: @@ -2926,8 +2928,6 @@ build_conditional_expr (tree ifexp, tree op1, tree op2) tree result_type = NULL; tree orig_op1 = op1, orig_op2 = op2; - ifexp = lang_hooks.truthvalue_conversion (default_conversion (ifexp)); - /* Promote both alternatives. */ if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE) @@ -7316,8 +7316,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, but that does not mean the operands should be converted to ints! */ result_type = integer_type_node; - op0 = lang_hooks.truthvalue_conversion (op0); - op1 = lang_hooks.truthvalue_conversion (op1); + op0 = c_common_truthvalue_conversion (op0); + op1 = c_common_truthvalue_conversion (op1); converted = 1; } break; @@ -7797,3 +7797,34 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, return result; } } + + +/* Convert EXPR to be a truth-value, validating its type for this + purpose. Passes EXPR to default_function_array_conversion. */ + +tree +c_objc_common_truthvalue_conversion (tree expr) +{ + expr = default_function_array_conversion (expr); + switch (TREE_CODE (TREE_TYPE (expr))) + { + case ARRAY_TYPE: + error ("used array that cannot be converted to pointer where scalar is required"); + return error_mark_node; + + case RECORD_TYPE: + error ("used struct type value where scalar is required"); + return error_mark_node; + + case UNION_TYPE: + error ("used union type value where scalar is required"); + return error_mark_node; + + default: + break; + } + + /* ??? Should we also give an error for void and vectors rather than + leaving those to give errors later? */ + return c_common_truthvalue_conversion (expr); +} |

