diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-11-06 12:39:36 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-11-06 12:39:36 +0000 |
commit | 207bf4854d656b1aa84cd244184cfefa5a680f78 (patch) | |
tree | c32872a1f39f18b63b6c13f757df788f6cd41cae /gcc/c-common.c | |
parent | 25cece2fbdf4b3d4122d1e49b77ef9d144c02a57 (diff) | |
download | gcc-207bf4854d656b1aa84cd244184cfefa5a680f78.zip gcc-207bf4854d656b1aa84cd244184cfefa5a680f78.tar.gz gcc-207bf4854d656b1aa84cd244184cfefa5a680f78.tar.bz2 |
re PR c/461 (non-lvalue arrays)
* c-common.c (c_expand_expr_stmt): Apply default conversions to
non-lvalue arrays if C99.
* c-typeck.c (default_conversion): Split out code handling
array-to-pointer and function-to-pointer conversions into a
separate default_function_array_conversion function.
(default_function_array_conversion): New function. Keep track of
whether any NON_LVALUE_EXPRs were stripped. Return non-lvalue
arrays unchanged outside C99 mode instead of giving an error for
them.
(build_component_ref): Use pedantic_non_lvalue when handling
COMPOUND_EXPR. Don't handle COND_EXPR specially.
(convert_arguments): Use default_function_array_conversion.
(build_unary_op): For ADDR_EXPR, take a flag indicating whether
non-lvalues are OK.
(unary_complex_lvalue): Likewise.
(internal_build_compound_expr): Use
default_function_array_conversion. Apply default conversions to
function in compound expression.
(build_c_cast, build_modify_expr, digest_init, build_asm_stmt):
Use default_function_array_conversion.
* doc/extend.texi: Update documentation of subscripting non-lvalue
arrays.
Fixes PR c/461.
testsuite:
* gcc.dg/c90-array-lval-1.c, gcc.dg/c90-array-lval-2.c,
gcc.dg/c99-array-lval-1.c, gcc.dg/c99-array-lval-2.c: Remove
XFAILs. Adjust expected error texts.
* gcc.c-torture/compile/20011106-1.c,
gcc.c-torture/compile/20011106-2.c, gcc.dg/c90-array-lval-3.c,
gcc.dg/c90-array-lval-4.c, gcc.dg/c90-array-lval-5.c,
gcc.dg/c99-array-lval-3.c, gcc.dg/c99-array-lval-4.c,
gcc.dg/c99-array-lval-5.c: New tests.
From-SVN: r46805
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index ee633a5..312060d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1181,7 +1181,8 @@ c_expand_expr_stmt (expr) { /* Do default conversion if safe and possibly important, in case within ({...}). */ - if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE && lvalue_p (expr)) + if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE + && (flag_isoc99 || lvalue_p (expr))) || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE) expr = default_conversion (expr); |