+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
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,
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. */
+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>
--- /dev/null
+/* 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 } */
--- /dev/null
+/* 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" } */
+}