diff options
author | Joseph Myers <joseph@codesourcery.com> | 2005-12-04 21:45:41 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2005-12-04 21:45:41 +0000 |
commit | 1344f9a3189ed48181c844c7d2cc1f70511ab898 (patch) | |
tree | 09a78feaae42dbb50fdaf694eca604caa1029b35 /gcc/c-common.c | |
parent | d77314ece616e1a2626ebd2f6abf55ecda0b440f (diff) | |
download | gcc-1344f9a3189ed48181c844c7d2cc1f70511ab898.zip gcc-1344f9a3189ed48181c844c7d2cc1f70511ab898.tar.gz gcc-1344f9a3189ed48181c844c7d2cc1f70511ab898.tar.bz2 |
c-common.c (binary_op_error): Do not allow NOP_EXPR.
* c-common.c (binary_op_error): Do not allow NOP_EXPR.
(c_common_truthvalue_conversion): Handle NOP_EXPR the same as
CONVERT_EXPR.
(check_function_arguments_recurse): Allow both NOP_EXPR and
CONVERT_EXPR but check conversions preserve precision.
* c-typeck.c (pointer_diff): Allow both NOP_EXPR and CONVERT_EXPR
but check conversions preserve precision.
(build_unary_op): Don't allow NOP_EXPR. Use gcc_unreachable () in
default case.
testsuite:
* gcc.dg/format/cast-1.c: New test.
From-SVN: r108020
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 898f394..27934dd 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1862,8 +1862,7 @@ min_precision (tree value, int unsignedp) } /* Print an error message for invalid operands to arith operation - CODE. NOP_EXPR is used as a special case (see - c_common_truthvalue_conversion). */ + CODE. */ void binary_op_error (enum tree_code code) @@ -1872,10 +1871,6 @@ binary_op_error (enum tree_code code) switch (code) { - case NOP_EXPR: - error ("invalid truth-value expression"); - return; - case PLUS_EXPR: opname = "+"; break; case MINUS_EXPR: @@ -2467,13 +2462,12 @@ c_common_truthvalue_conversion (tree expr) c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))); case CONVERT_EXPR: + case NOP_EXPR: /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE, since that affects how `default_conversion' will behave. */ if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE) break; - /* Fall through.... */ - case NOP_EXPR: /* If this is widening the argument, we can ignore it. */ if (TYPE_PRECISION (TREE_TYPE (expr)) >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0)))) @@ -5614,7 +5608,9 @@ check_function_arguments_recurse (void (*callback) void *ctx, tree param, unsigned HOST_WIDE_INT param_num) { - if (TREE_CODE (param) == NOP_EXPR) + if ((TREE_CODE (param) == NOP_EXPR || TREE_CODE (param) == CONVERT_EXPR) + && (TYPE_PRECISION (TREE_TYPE (param)) + == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (param, 0))))) { /* Strip coercion. */ check_function_arguments_recurse (callback, ctx, |