diff options
author | Mark Shinwell <shinwell@codesourcery.com> | 2006-10-18 10:57:18 +0000 |
---|---|---|
committer | Mark Shinwell <shinwell@gcc.gnu.org> | 2006-10-18 10:57:18 +0000 |
commit | 8e76c2bf138ad82a0b66a75a12e9529ced0930d8 (patch) | |
tree | 2da6360f1136b2a239a3c31654af3dfc84ff0dbe | |
parent | 94d3995aa3649d777794b8a70c9b8ea21bdfdd04 (diff) | |
download | gcc-8e76c2bf138ad82a0b66a75a12e9529ced0930d8.zip gcc-8e76c2bf138ad82a0b66a75a12e9529ced0930d8.tar.gz gcc-8e76c2bf138ad82a0b66a75a12e9529ced0930d8.tar.bz2 |
re PR c++/26884 (Misleading diagnostic for invalid array initializer)
PR c++/26884
* typeck2.c (digest_init): Raise error upon attempts to
initialize arrays with variables.
From-SVN: r117854
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2358e9b..356bc25 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-10-18 Mark Shinwell <shinwell@codesourcery.com> + + PR c++/26884 + * typeck2.c (digest_init): Raise error upon attempts to + initialize arrays with variables. + 2006-10-17 Lee Millward <lee.millward@codesourcery.com> PR c++/27952 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 12987cf..a3654c0 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -733,6 +733,15 @@ digest_init (tree type, tree init) return error_mark_node; } + + if (TREE_CODE (type) == ARRAY_TYPE + && TREE_CODE (init) != CONSTRUCTOR) + { + error ("array must be initialized with a brace-enclosed" + " initializer"); + return error_mark_node; + } + return convert_for_initialization (NULL_TREE, type, init, LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING, "initialization", NULL_TREE, 0); |