This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 e500] fix vector array initializers for c++
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 Jan 2004 15:59:08 -0400
- Subject: [3.3 e500] fix vector array initializers for c++
I've backported this patch to the 3.3-e500 branch.
Incidentally, a variant of this test is broken on mainline, but for an
entirely different reason. Will take a look shortly...
Committed.
2003-06-03 Jason Merrill <jason@redhat.com>
* cp/cp-tree.h (CP_AGGREGATE_TYPE_P): Accept vectors.
* cp/decl.c (reshape_init): Handle vectors.
* testsuite/g++.dg/init/array10.C: New.
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.776.2.15.2.1
diff -c -p -r1.776.2.15.2.1 cp-tree.h
*** cp/cp-tree.h 4 Sep 2003 22:19:53 -0000 1.776.2.15.2.1
--- cp/cp-tree.h 29 Jan 2004 19:52:50 -0000
*************** struct lang_decl GTY(())
*** 2546,2554 ****
An aggregate is an array or a class with no user-declared
constructors, no private or protected non-static data members, no
! base classes, and no virtual functions. */
#define CP_AGGREGATE_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == ARRAY_TYPE \
|| (CLASS_TYPE_P (TYPE) \
&& !CLASSTYPE_NON_AGGREGATE (TYPE)))
--- 2546,2557 ----
An aggregate is an array or a class with no user-declared
constructors, no private or protected non-static data members, no
! base classes, and no virtual functions.
!
! As an extension, we also treat vectors as aggregates. */
#define CP_AGGREGATE_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == ARRAY_TYPE \
+ || TREE_CODE (TYPE) == VECTOR_TYPE \
|| (CLASS_TYPE_P (TYPE) \
&& !CLASSTYPE_NON_AGGREGATE (TYPE)))
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.35.2.3
diff -c -p -r1.965.2.35.2.3 decl.c
*** cp/decl.c 4 Sep 2003 22:19:54 -0000 1.965.2.35.2.3
--- cp/decl.c 29 Jan 2004 19:52:58 -0000
*************** reshape_init (tree type, tree *initp)
*** 8216,8222 ****
/* If the initializer is brace-enclosed, pull initializers from the
enclosed elements. Advance past the brace-enclosed initializer
now. */
! if (TREE_CODE (old_init_value) == CONSTRUCTOR
&& TREE_HAS_CONSTRUCTOR (old_init_value))
{
*initp = TREE_CHAIN (old_init);
--- 8216,8223 ----
/* If the initializer is brace-enclosed, pull initializers from the
enclosed elements. Advance past the brace-enclosed initializer
now. */
! if (TREE_CODE (old_init_value) == CONSTRUCTOR
! && TREE_TYPE (old_init_value) == NULL_TREE
&& TREE_HAS_CONSTRUCTOR (old_init_value))
{
*initp = TREE_CHAIN (old_init);
*************** reshape_init (tree type, tree *initp)
*** 8261,8268 ****
non-empty subaggregate, brace elision is assumed and the
initializer is considered for the initialization of the first
member of the subaggregate. */
! if (CLASS_TYPE_P (type)
! && !brace_enclosed_p
&& can_convert_arg (type, TREE_TYPE (old_init_value), old_init_value))
{
*initp = TREE_CHAIN (old_init);
--- 8262,8268 ----
non-empty subaggregate, brace elision is assumed and the
initializer is considered for the initialization of the first
member of the subaggregate. */
! if (!brace_enclosed_p
&& can_convert_arg (type, TREE_TYPE (old_init_value), old_init_value))
{
*initp = TREE_CHAIN (old_init);
Index: testsuite/g++.dg/init/array10.C
===================================================================
RCS file: testsuite/g++.dg/init/array10.C
diff -N testsuite/g++.dg/init/array10.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/array10.C 29 Jan 2004 19:52:58 -0000
***************
*** 0 ****
--- 1,6 ----
+ // { dg-do compile }
+ // { dg-options "" }
+
+ typedef int __attribute__((mode(V2SI))) vec;
+
+ vec foo[] = { (vec) {1, 2} };