This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59032] [4.8/4.9 Regression] ICE incrementing vector type
- From: "vries at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 10 Nov 2013 20:34:51 +0000
- Subject: [Bug c++/59032] [4.8/4.9 Regression] ICE incrementing vector type
- Auto-submitted: auto-generated
- References: <bug-59032-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59032
--- Comment #4 from vries at gcc dot gnu.org ---
> We already support v=v+1, so it wouldn't be a large extension.
Hmm, indeed. If found some code in cp_builld_binary_op marked with this
comment:
...
/* In case when one of the operands of the binary operation is
a vector and another is a scalar -- convert scalar to vector. */
...
I've tried to do something similar in cp_build_unary_op. Tentative patch:
...
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index bcb8782..0554664 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5746,7 +5746,38 @@ cp_build_unary_op (enum tree_code code, tree xarg, int
noconvert,
else
inc = integer_one_node;
- inc = cp_convert (argtype, inc, complain);
+ /* In case when the operand of the unary operation is a vector --
+ convert scalar inc to vector. */
+ if (TREE_CODE (TREE_TYPE (arg)) == VECTOR_TYPE)
+ {
+ enum stv_conv convert_flag;
+ enum tree_code pm_code = ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? PLUS_EXPR
+ : MINUS_EXPR);
+
+ convert_flag = scalar_to_vector (input_location, pm_code, arg, inc,
+ complain & tf_error);
+
+ switch (convert_flag)
+ {
+ case stv_error:
+ return error_mark_node;
+ case stv_firstarg:
+ gcc_unreachable ();
+ case stv_secondarg:
+ {
+ inc = save_expr (inc);
+ inc = convert (TREE_TYPE (TREE_TYPE (arg)), inc);
+ inc = build_vector_from_val (TREE_TYPE (arg), inc);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ else
+ inc = cp_convert (argtype, inc, complain);
/* If 'arg' is an Objective-C PROPERTY_REF expression, then we
need to ask Objective-C to build the increment or decrement
...