[PATCH] Fix PR c++/26884
Mark Shinwell
shinwell@codesourcery.com
Fri Oct 6 13:08:00 GMT 2006
I think the following is a suitable fix for 26884, although I'm a
novice when it comes to gcc front-end work :-) No regressions on
i686-pc-linux-gnu. OK?
Mark
--
gcc/
2006-10-06 Mark Shinwell <shinwell@codesourcery.com>
PR c++/26884
* cp/typeck2.c (digest_init): Raise error upon attempts to
initialize arrays with variables.
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c (revision 117455)
+++ gcc/cp/typeck2.c (working copy)
@@ -733,6 +733,14 @@ digest_init (tree type, tree init)
return error_mark_node;
}
+
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && (TREE_CODE (init) == VAR_DECL || TREE_CODE (init) == PARM_DECL))
+ {
+ error ("cannot initialize array with a variable");
+ return error_mark_node;
+ }
+
return convert_for_initialization (NULL_TREE, type, init,
LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING,
"initialization", NULL_TREE, 0);
More information about the Gcc-patches
mailing list