diff options
author | Richard Stallman <rms@gnu.org> | 1993-04-30 00:54:54 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-04-30 00:54:54 +0000 |
commit | e855c5ce209b9f33af29453f7464611b8c8089d6 (patch) | |
tree | 2dc1d34b31e74fdc94a8b9259d9a4f4bb2216a9a | |
parent | b61cccc2679a54d9de32ed5e5d9d1f61901a1bdf (diff) | |
download | gcc-e855c5ce209b9f33af29453f7464611b8c8089d6.zip gcc-e855c5ce209b9f33af29453f7464611b8c8089d6.tar.gz gcc-e855c5ce209b9f33af29453f7464611b8c8089d6.tar.bz2 |
(default_conversion): Pass through non-lvalue arrays without any conversion and/or error messages.
(default_conversion): Pass through non-lvalue arrays
without any conversion and/or error messages. Such operands are
perfectly OK in many contexts.
(build_conditional_expr): Do default_conversion
before testing for ERROR_MARK.
From-SVN: r4281
-rw-r--r-- | gcc/c-typeck.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 624c621..1ee4579 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -986,8 +986,8 @@ default_conversion (exp) if (!lvalue_p (exp) && ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp))) { - error ("invalid use of non-lvalue array"); - return error_mark_node; + /* Non-lvalue arrays do not decay into pointers. */ + return exp; } if (TYPE_READONLY (type) || TYPE_VOLATILE (type)) @@ -3560,11 +3560,6 @@ build_conditional_expr (ifexp, op1, op2) ifexp = truthvalue_conversion (default_conversion (ifexp)); - if (TREE_CODE (ifexp) == ERROR_MARK - || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK - || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK) - return error_mark_node; - #if 0 /* Produces wrong result if within sizeof. */ /* Don't promote the operands separately if they promote the same way. Return the unpromoted type and let the combined @@ -3582,13 +3577,18 @@ build_conditional_expr (ifexp, op1, op2) } #endif - /* They don't match; promote them both and then try to reconcile them. */ + /* Promote both alternatives. */ if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE) op1 = default_conversion (op1); if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE) op2 = default_conversion (op2); + if (TREE_CODE (ifexp) == ERROR_MARK + || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK + || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK) + return error_mark_node; + type1 = TREE_TYPE (op1); code1 = TREE_CODE (type1); type2 = TREE_TYPE (op2); |