summaryrefslogtreecommitdiff
path: root/gcc/tree-nested.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-26 18:10:58 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-26 18:10:58 +0000
commit76d042abe6f6f481cc2ad2370b8255e442abebd8 (patch)
tree363a6e44b0cedce330dc22f91e904959a53d14b3 /gcc/tree-nested.c
parenta5297f53d7a927ce2440b2f6ddae91e8a3d3de90 (diff)
downloadgcc-76d042abe6f6f481cc2ad2370b8255e442abebd8.tar.gz
PR middle-end/25261
PR middle-end/28790 * tree-nested.c (struct nesting_info): Added static_chain_added. (convert_call_expr): Set static_chain_added when adding static chain. Handle OMP_PARALLEL and OMP_SECTION. * gcc.dg/gomp/nestedfn-1.c: New test. * testsuite/libgomp.c/nestedfn-4.c: New test. * testsuite/libgomp.c/nestedfn-5.c: New test. * testsuite/libgomp.fortran/nestedfn3.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-nested.c')
-rw-r--r--gcc/tree-nested.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 591642c732c..7467dca84e6 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1,5 +1,5 @@
/* Nested function decomposition for trees.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GCC.
@@ -104,6 +104,7 @@ struct nesting_info GTY ((chain_next ("%h.next")))
bool any_parm_remapped;
bool any_tramp_created;
+ char static_chain_added;
};
@@ -1626,6 +1627,8 @@ convert_call_expr (tree *tp, int *walk_subtrees, void *data)
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
struct nesting_info *info = wi->info;
tree t = *tp, decl, target_context;
+ char save_static_chain_added;
+ int i;
*walk_subtrees = 0;
switch (TREE_CODE (t))
@@ -1636,8 +1639,12 @@ convert_call_expr (tree *tp, int *walk_subtrees, void *data)
break;
target_context = decl_function_context (decl);
if (target_context && !DECL_NO_STATIC_CHAIN (decl))
- TREE_OPERAND (t, 2)
- = get_static_chain (info, target_context, &wi->tsi);
+ {
+ TREE_OPERAND (t, 2)
+ = get_static_chain (info, target_context, &wi->tsi);
+ info->static_chain_added
+ |= (1 << (info->context != target_context));
+ }
break;
case RETURN_EXPR:
@@ -1647,8 +1654,36 @@ convert_call_expr (tree *tp, int *walk_subtrees, void *data)
*walk_subtrees = 1;
break;
+ case OMP_PARALLEL:
+ save_static_chain_added = info->static_chain_added;
+ info->static_chain_added = 0;
+ walk_body (convert_call_expr, info, &OMP_PARALLEL_BODY (t));
+ for (i = 0; i < 2; i++)
+ {
+ tree c, decl;
+ if ((info->static_chain_added & (1 << i)) == 0)
+ continue;
+ decl = i ? get_chain_decl (info) : info->frame_decl;
+ /* Don't add CHAIN.* or FRAME.* twice. */
+ for (c = OMP_PARALLEL_CLAUSES (t); c; c = OMP_CLAUSE_CHAIN (c))
+ if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED)
+ && OMP_CLAUSE_DECL (c) == decl)
+ break;
+ if (c == NULL)
+ {
+ c = build_omp_clause (OMP_CLAUSE_FIRSTPRIVATE);
+ OMP_CLAUSE_DECL (c) = decl;
+ OMP_CLAUSE_CHAIN (c) = OMP_PARALLEL_CLAUSES (t);
+ OMP_PARALLEL_CLAUSES (t) = c;
+ }
+ }
+ info->static_chain_added |= save_static_chain_added;
+ break;
+
case OMP_FOR:
case OMP_SECTIONS:
+ case OMP_SECTION:
case OMP_SINGLE:
case OMP_MASTER:
case OMP_ORDERED: