From 6698175d1591c25041f3979a5c01ef5f81e2f4ff Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 6 May 2013 23:11:24 +0200 Subject: [PATCH] typeck.c (cp_build_binary_op): Call save_expr before build_vector_from_val. 2013-05-06 Marc Glisse gcc/cp/ * typeck.c (cp_build_binary_op): Call save_expr before build_vector_from_val. gcc/testsuite/ * c-c++-common/vector-scalar-2.c: New testcase. From-SVN: r198648 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 2 ++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/vector-scalar-2.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/vector-scalar-2.c diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 387f44a..21c4e39 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-05-06 Marc Glisse + + * typeck.c (cp_build_binary_op): Call save_expr before + build_vector_from_val. + 2013-05-06 Paolo Carlini PR c++/57183 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b761dd5..2d9711b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3972,6 +3972,7 @@ cp_build_binary_op (location_t location, return error_mark_node; case stv_firstarg: { + op0 = save_expr (op0); op0 = convert (TREE_TYPE (type1), op0); op0 = build_vector_from_val (type1, op0); type0 = TREE_TYPE (op0); @@ -3981,6 +3982,7 @@ cp_build_binary_op (location_t location, } case stv_secondarg: { + op1 = save_expr (op1); op1 = convert (TREE_TYPE (type0), op1); op1 = build_vector_from_val (type0, op1); type1 = TREE_TYPE (op1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73d27cf..dc8c10e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-05-06 Marc Glisse + + * c-c++-common/vector-scalar-2.c: New testcase. + 2013-05-06 Maxim Kuznetsov * gcc.target/i386/asm-dialect-2.c: New testcase. diff --git a/gcc/testsuite/c-c++-common/vector-scalar-2.c b/gcc/testsuite/c-c++-common/vector-scalar-2.c new file mode 100644 index 0000000..f624c4c --- /dev/null +++ b/gcc/testsuite/c-c++-common/vector-scalar-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); + +int c; + +void f (veci *a) +{ + *a = *a + ++c; +} + +/* { dg-final { scan-tree-dump-times " \\\+ 1" 1 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ -- 2.7.4