From 071f6d39ee3232ddbcae388a6167b04a53417b80 Mon Sep 17 00:00:00 2001 From: kyukhin Date: Wed, 4 Jun 2014 10:07:21 +0000 Subject: [PATCH] gcc/c/ PR c/58942 * c-array-notation.c (fix_builtin_array_notation_fn): Handle the case with a pointer. gcc/cp/ PR c/58942 * cp-array-notation.c (expand_sec_reduce_builtin): Handle the case with a pointer. gcc/testsuite/ PR c/58942 * c-c++-common/cilk-plus/AN/pr58942.c: Check for correct handling of the case with a pointer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211220 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-array-notation.c | 4 +++- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-array-notation.c | 2 ++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c | 8 ++++++++ 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1047a65b636..c51bfb49580 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-06-04 Igor Zamyatin + + PR c/58942 + * c-array-notation.c (fix_builtin_array_notation_fn): Handle the case + with a pointer. + 2014-06-03 Marek Polacek PR c/60439 diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index a0fe2fbbee8..b4015b84ee9 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -310,7 +310,9 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var) || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND) array_ind_value = build_decl (location, VAR_DECL, NULL_TREE, TREE_TYPE (func_parm)); - array_op0 = (*array_operand)[0]; + array_op0 = (*array_operand)[0]; + if (TREE_CODE (array_op0) == INDIRECT_REF) + array_op0 = TREE_OPERAND (array_op0, 0); switch (an_type) { case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a22842bf17..334d6b1f3c4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-06-04 Igor Zamyatin + + PR c/58942 + * cp-array-notation.c (expand_sec_reduce_builtin): Handle the case + with a pointer. + 2014-06-03 Paolo Carlini DR 1423 diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index ff82deee7be..0538e559f85 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -340,6 +340,8 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var) array_ind_value = get_temp_regvar (TREE_TYPE (func_parm), func_parm); array_op0 = (*array_operand)[0]; + if (TREE_CODE (array_op0) == INDIRECT_REF) + array_op0 = TREE_OPERAND (array_op0, 0); switch (an_type) { case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f1878b6dece..4146bde92b7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-06-04 Igor Zamyatin + + PR c/58942 + * c-c++-common/cilk-plus/AN/pr58942.c: Check for correct handling of + the case with a pointer. + 2014-06-04 Marek Polacek PR c/30020 diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c new file mode 100644 index 00000000000..87903af3c86 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr58942.c @@ -0,0 +1,8 @@ +/* PR c/58942 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int foo (int*p, int i) +{ + return __sec_reduce_max_ind(p[1:i]); +} -- 2.11.4.GIT