diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b40c63ad6f..e010e7867cc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-08-16 Ian Lance Taylor + + PR c++/23337 + * gimplify.c (gimplify_init_ctor_eval): If we see an element of + vector type, don't try to construct it element by element. Add an + assertion that we use a FIELD_DECL when building a COMPONENT_REF. + 2005-08-16 Volker Reichelt * fold-const.c (fold_ternary): Simplify folding of a CALL_EXPR. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index a1ef22e0d2b..41ca3b3bbb2 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2593,10 +2593,14 @@ gimplify_init_ctor_eval (tree object, VEC(constructor_elt,gc) *elts, purpose, NULL_TREE, NULL_TREE); } else - cref = build (COMPONENT_REF, TREE_TYPE (purpose), - unshare_expr (object), purpose, NULL_TREE); + { + gcc_assert (TREE_CODE (purpose) == FIELD_DECL); + cref = build (COMPONENT_REF, TREE_TYPE (purpose), + unshare_expr (object), purpose, NULL_TREE); + } - if (TREE_CODE (value) == CONSTRUCTOR) + if (TREE_CODE (value) == CONSTRUCTOR + && TREE_CODE (TREE_TYPE (value)) != VECTOR_TYPE) gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value), pre_p, cleared); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 179e2dc99b5..043d4c7e1e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-08-16 Ian Lance Taylor + + PR c++/23337 + * g++.dg/ext/vector2.C: New. + 2005-08-16 Thomas Koenig PR libfortran/23428 diff --git a/gcc/testsuite/g++.dg/ext/vector2.C b/gcc/testsuite/g++.dg/ext/vector2.C new file mode 100644 index 00000000000..d93257b1969 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector2.C @@ -0,0 +1,12 @@ +// PR c++/23337; caused an ICE in component_ref_field_offset +// { dg-options "" } +// { dg-options "-mmmx" { target { i?86-*-* && ilp32 } } } */ +// { dg-options "-mmmx" { target { x86_64-*-* && ilp32 } } } */ +typedef int vec __attribute__ ((vector_size (8))); +extern int bar (vec); +int +foo (int i) +{ + vec a[] = { (vec) { 0, i }, (vec) { 4, 5 } }; + return bar (a[0]) + bar (a[1]); +}