aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-06-25 11:17:48 -0400
committerJason Merrill <jason@gcc.gnu.org>2012-06-25 11:17:48 -0400
commit443679ae80afd9cc621d0d6bae5d431a294d0ec2 (patch)
tree853553ea31a3551d4a7d17c985d0352b6babfd6b /gcc
parent85d917484f771cd78ae2089f5d901d3c86f7ff6e (diff)
downloadgcc-443679ae80afd9cc621d0d6bae5d431a294d0ec2.zip
gcc-443679ae80afd9cc621d0d6bae5d431a294d0ec2.tar.gz
gcc-443679ae80afd9cc621d0d6bae5d431a294d0ec2.tar.bz2
re PR c++/53565 (FAIL: libgomp.c++/for-7.C)
PR c++/53565 * pt.c (tsubst_omp_for_iterator): Simplify DECL_EXPR handling. (tsubst_expr) [OMP_FOR]: Here, too. From-SVN: r188939
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c49
-rw-r--r--gcc/testsuite/g++.dg/gomp/for-19.C4
3 files changed, 23 insertions, 36 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 93233a89..df3a917 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-25 Jason Merrill <jason@redhat.com>
+
+ PR c++/53565
+ * pt.c (tsubst_omp_for_iterator): Simplify DECL_EXPR handling.
+ (tsubst_expr) [OMP_FOR]: Here, too.
+
2012-06-25 Jakub Jelinek <jakub@redhat.com>
PR c++/53594
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5e02c8c..ad7134b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12659,22 +12659,24 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
#define RECUR(NODE) \
tsubst_expr ((NODE), args, complain, in_decl, \
integral_constant_expression_p)
- tree decl, init, cond, incr, auto_node;
+ tree decl, init, cond, incr;
+ bool init_decl;
init = TREE_VEC_ELT (OMP_FOR_INIT (t), i);
gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
- decl = RECUR (TREE_OPERAND (init, 0));
+ decl = TREE_OPERAND (init, 0);
init = TREE_OPERAND (init, 1);
- auto_node = type_uses_auto (TREE_TYPE (decl));
- if (auto_node && init)
+ /* Do this before substituting into decl to handle 'auto'. */
+ init_decl = (init && TREE_CODE (init) == DECL_EXPR);
+ init = RECUR (init);
+ decl = RECUR (decl);
+ if (init_decl)
{
- tree init_expr = init;
- if (TREE_CODE (init_expr) == DECL_EXPR)
- init_expr = DECL_INITIAL (DECL_EXPR_DECL (init_expr));
- init_expr = RECUR (init_expr);
- TREE_TYPE (decl)
- = do_auto_deduction (TREE_TYPE (decl), init_expr, auto_node);
+ gcc_assert (!processing_template_decl);
+ init = DECL_INITIAL (decl);
+ DECL_INITIAL (decl) = NULL_TREE;
}
+
gcc_assert (!type_dependent_expression_p (decl));
if (!CLASS_TYPE_P (TREE_TYPE (decl)))
@@ -12695,7 +12697,7 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
return;
}
- if (init && TREE_CODE (init) != DECL_EXPR)
+ if (init && !init_decl)
{
tree c;
for (c = *clauses; c ; c = OMP_CLAUSE_CHAIN (c))
@@ -13189,34 +13191,13 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
condv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t)));
incrv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t)));
+ stmt = begin_omp_structured_block ();
+
for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (t)); i++)
tsubst_omp_for_iterator (t, i, declv, initv, condv, incrv,
&clauses, args, complain, in_decl,
integral_constant_expression_p);
- stmt = begin_omp_structured_block ();
-
- for (i = 0; i < TREE_VEC_LENGTH (initv); i++)
- if (TREE_VEC_ELT (initv, i) == NULL
- || TREE_CODE (TREE_VEC_ELT (initv, i)) != DECL_EXPR)
- TREE_VEC_ELT (initv, i) = RECUR (TREE_VEC_ELT (initv, i));
- else if (CLASS_TYPE_P (TREE_TYPE (TREE_VEC_ELT (initv, i))))
- {
- tree init = RECUR (TREE_VEC_ELT (initv, i));
- gcc_assert (init == TREE_VEC_ELT (declv, i));
- TREE_VEC_ELT (initv, i) = NULL_TREE;
- }
- else
- {
- tree decl_expr = TREE_VEC_ELT (initv, i);
- tree init = DECL_INITIAL (DECL_EXPR_DECL (decl_expr));
- gcc_assert (init != NULL);
- TREE_VEC_ELT (initv, i) = RECUR (init);
- DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = NULL;
- RECUR (decl_expr);
- DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = init;
- }
-
pre_body = push_stmt_list ();
RECUR (OMP_FOR_PRE_BODY (t));
pre_body = pop_stmt_list (pre_body);
diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C
index 7c56719..4441a29 100644
--- a/gcc/testsuite/g++.dg/gomp/for-19.C
+++ b/gcc/testsuite/g++.dg/gomp/for-19.C
@@ -26,8 +26,8 @@ template <typename T>
void
f3 (void)
{
-#pragma omp for // { dg-error "forbids incrementing a pointer of type" }
- for (T q = T (p); q < T (p + 4); q++)
+#pragma omp for
+ for (T q = T (p); q < T (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" }
;
}