re PR c/12446 (ICE in emit_move_insn on complicated array reference)
PR c/12446 * c-typeck.c (convert_for_assignment): Issue an error for array to pointer assignment after default conversion. (digest_init): Likewise. From-SVN: r72096
This commit is contained in:
parent
e9ff9b17a7
commit
b494fd9851
@ -1,3 +1,10 @@
|
||||
2003-10-04 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
PR c/12446
|
||||
* c-typeck.c (convert_for_assignment): Issue an error for
|
||||
array to pointer assignment after default conversion.
|
||||
(digest_init): Likewise.
|
||||
|
||||
2003-10-04 Fariborz Jahanian <fjahanian@apple.com>
|
||||
|
||||
* c-decl.c (duplicate_decls): retain DECL_COMMON of old declaration
|
||||
|
@ -3556,6 +3556,11 @@ convert_for_assignment (tree type, tree rhs, const char *errtype,
|
||||
errtype, funname, parmnum);
|
||||
return convert (type, rhs);
|
||||
}
|
||||
else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
|
||||
{
|
||||
error ("invalid use of non-lvalue array");
|
||||
return error_mark_node;
|
||||
}
|
||||
else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
|
||||
{
|
||||
/* An explicit constant 0 can convert to a pointer,
|
||||
@ -4052,8 +4057,16 @@ digest_init (tree type, tree init, int require_constant)
|
||||
TREE_TYPE (type), COMPARE_STRICT))))
|
||||
{
|
||||
if (code == POINTER_TYPE)
|
||||
inside_init = default_function_array_conversion (inside_init);
|
||||
|
||||
{
|
||||
inside_init = default_function_array_conversion (inside_init);
|
||||
|
||||
if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
|
||||
{
|
||||
error_init ("invalid use of non-lvalue array");
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
|
||||
if (code == VECTOR_TYPE)
|
||||
/* Although the types are compatible, we may require a
|
||||
conversion. */
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-10-04 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
* gcc.dg/c90-array-lval-6.c: New test.
|
||||
* gcc.dg/c99-array-lval-6.c: New test.
|
||||
|
||||
2003-10-03 Alexander Malmberg <alexander@malmberg.org>
|
||||
Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
|
16
gcc/testsuite/gcc.dg/c90-array-lval-6.c
Normal file
16
gcc/testsuite/gcc.dg/c90-array-lval-6.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* PR c/12446 */
|
||||
/* Origin: Keith Thompson <kst@cts.com> */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
|
||||
|
||||
|
||||
struct s { char c[1]; };
|
||||
|
||||
extern struct s foo(void);
|
||||
|
||||
void bar(void)
|
||||
{
|
||||
char *ptr = foo().c; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
}
|
||||
/* { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 14 } */
|
15
gcc/testsuite/gcc.dg/c99-array-lval-6.c
Normal file
15
gcc/testsuite/gcc.dg/c99-array-lval-6.c
Normal file
@ -0,0 +1,15 @@
|
||||
/* PR c/12446 */
|
||||
/* Origin: Keith Thompson <kst@cts.com> */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
||||
|
||||
|
||||
struct s { char c[1]; };
|
||||
|
||||
extern struct s foo(void);
|
||||
|
||||
void bar(void)
|
||||
{
|
||||
char *ptr = foo().c; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */
|
||||
}
|
Loading…
Reference in New Issue
Block a user