This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Don't ICE on vla = { }; (PR c++/42059)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 16 Nov 2009 20:32:40 +0100
- Subject: [C++ PATCH] Don't ICE on vla = { }; (PR c++/42059)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
We reject
void foo (int i) { int a[i] = {}; }
so IMHO we should also reject
void foo (int i) { int a[i]; a = {}; }
instead of ICEing on it.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.4?
2009-11-16 Jakub Jelinek <jakub@redhat.com>
PR c++/42059
* typeck.c (cp_build_modify_expr): For initializer list call
check_array_initializer to make sure lhs isn't a VLA.
* g++.dg/cpp0x/initlist26.C: New test.
--- gcc/cp/typeck.c.jj 2009-11-13 11:13:20.000000000 +0100
+++ gcc/cp/typeck.c 2009-11-16 14:38:56.000000000 +0100
@@ -6239,7 +6239,11 @@ cp_build_modify_expr (tree lhs, enum tre
int from_array;
if (BRACE_ENCLOSED_INITIALIZER_P (rhs))
- rhs = digest_init (lhstype, rhs);
+ {
+ if (check_array_initializer (lhs, lhstype, rhs))
+ return error_mark_node;
+ rhs = digest_init (lhstype, rhs);
+ }
else if (!same_or_base_type_p (TYPE_MAIN_VARIANT (lhstype),
TYPE_MAIN_VARIANT (TREE_TYPE (rhs))))
--- gcc/testsuite/g++.dg/cpp0x/initlist26.C.jj 2009-11-16 14:43:55.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/initlist26.C 2009-11-16 14:44:05.000000000 +0100
@@ -0,0 +1,10 @@
+// PR c++/42059
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+void
+foo (int i)
+{
+ int a[i];
+ a = { }; // { dg-error "may not be initialized" }
+}
Jakub