aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-06-17 20:01:05 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2015-06-17 20:01:05 +0200
commit64b5fcfa3bc6ac1d5f0bab9d5de3a8cd2259d70e (patch)
tree92044082e42a4af15c4b09548ef58e9de84438d5 /gcc
parent8c8b9f3265820507a1a9472fee7384b265692380 (diff)
downloadgcc-64b5fcfa3bc6ac1d5f0bab9d5de3a8cd2259d70e.zip
gcc-64b5fcfa3bc6ac1d5f0bab9d5de3a8cd2259d70e.tar.gz
gcc-64b5fcfa3bc6ac1d5f0bab9d5de3a8cd2259d70e.tar.bz2
re PR c++/66571 (Template substitution causes some OpenMP rejects-valid)
PR c++/66571 * pt.c (tsubst_omp_clause_decl): New function. (tsubst_omp_clauses): Use it or tsubst_copy instead of tsubst_expr on OMP_CLAUSE_DECL. * g++.dg/gomp/pr66571-1.C: New test. From-SVN: r224569
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c54
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr66571-1.C37
4 files changed, 87 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 98dab4a..010442f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/66571
+ * g++.dg/gomp/pr66571-1.C: New test.
+
2015-06-17 Andrew MacLeod <amacleod@redhat.com>
* cp-lang.c (cxx_dwarf_name): Use anon_aggrname_p.
@@ -7,7 +12,6 @@
* pt.c (push_template_decl_real): Likewise.
* name-lookup.c (make_anon_name): Use anon_aggrname_format.
-
2015-06-17 Andrew MacLeod <amacleod@redhat.com>
* call.c: Do not include input.h, line-map.h or is-a.h.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 60b9498..ccce90d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13489,6 +13489,32 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
}
}
+/* Helper function for tsubst_omp_clauses, used for instantiation of
+ OMP_CLAUSE_DECL of clauses that handles also OpenMP array sections
+ represented with TREE_LIST. */
+
+static tree
+tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain,
+ tree in_decl)
+{
+ if (TREE_CODE (decl) == TREE_LIST)
+ {
+ tree low_bound
+ = tsubst_expr (TREE_PURPOSE (decl), args, complain, in_decl,
+ /*integral_constant_expression_p=*/false);
+ tree length = tsubst_expr (TREE_VALUE (decl), args, complain, in_decl,
+ /*integral_constant_expression_p=*/false);
+ tree chain = tsubst_omp_clause_decl (TREE_CHAIN (decl), args, complain,
+ in_decl);
+ if (TREE_PURPOSE (decl) == low_bound
+ && TREE_VALUE (decl) == length
+ && TREE_CHAIN (decl) == chain)
+ return decl;
+ return tree_cons (low_bound, length, chain);
+ }
+ return tsubst_copy (decl, args, complain, in_decl);
+}
+
/* Like tsubst_copy, but specifically for OpenMP clauses. */
static tree
@@ -13520,16 +13546,23 @@ tsubst_omp_clauses (tree clauses, bool declare_simd,
case OMP_CLAUSE_FIRSTPRIVATE:
case OMP_CLAUSE_COPYIN:
case OMP_CLAUSE_COPYPRIVATE:
+ case OMP_CLAUSE_UNIFORM:
+ OMP_CLAUSE_DECL (nc) = tsubst_copy (OMP_CLAUSE_DECL (oc), args,
+ complain, in_decl);
+ break;
+ case OMP_CLAUSE_DEPEND:
+ case OMP_CLAUSE_FROM:
+ case OMP_CLAUSE_TO:
+ case OMP_CLAUSE_MAP:
+ OMP_CLAUSE_DECL (nc)
+ = tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain,
+ in_decl);
+ break;
case OMP_CLAUSE_IF:
case OMP_CLAUSE_NUM_THREADS:
case OMP_CLAUSE_SCHEDULE:
case OMP_CLAUSE_COLLAPSE:
case OMP_CLAUSE_FINAL:
- case OMP_CLAUSE_DEPEND:
- case OMP_CLAUSE_FROM:
- case OMP_CLAUSE_TO:
- case OMP_CLAUSE_UNIFORM:
- case OMP_CLAUSE_MAP:
case OMP_CLAUSE_DEVICE:
case OMP_CLAUSE_DIST_SCHEDULE:
case OMP_CLAUSE_NUM_TEAMS:
@@ -13556,20 +13589,17 @@ tsubst_omp_clauses (tree clauses, bool declare_simd,
else
gcc_assert (identifier_p (placeholder));
}
- OMP_CLAUSE_OPERAND (nc, 0)
- = tsubst_expr (OMP_CLAUSE_OPERAND (oc, 0), args, complain,
- in_decl, /*integral_constant_expression_p=*/false);
+ OMP_CLAUSE_DECL (nc) = tsubst_copy (OMP_CLAUSE_DECL (oc), args,
+ complain, in_decl);
break;
case OMP_CLAUSE_LINEAR:
case OMP_CLAUSE_ALIGNED:
- OMP_CLAUSE_OPERAND (nc, 0)
- = tsubst_expr (OMP_CLAUSE_OPERAND (oc, 0), args, complain,
- in_decl, /*integral_constant_expression_p=*/false);
+ OMP_CLAUSE_DECL (nc) = tsubst_copy (OMP_CLAUSE_DECL (oc), args,
+ complain, in_decl);
OMP_CLAUSE_OPERAND (nc, 1)
= tsubst_expr (OMP_CLAUSE_OPERAND (oc, 1), args, complain,
in_decl, /*integral_constant_expression_p=*/false);
break;
-
case OMP_CLAUSE_NOWAIT:
case OMP_CLAUSE_ORDERED:
case OMP_CLAUSE_DEFAULT:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 10c61ef..7d774cb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2015-06-17 Jakub Jelinek <jakub@redhat.com>
+ PR c++/66571
+ * g++.dg/gomp/pr66571-1.C: New test.
+
PR middle-end/66429
* c-c++-common/gomp/pr66429.c: New test.
diff --git a/gcc/testsuite/g++.dg/gomp/pr66571-1.C b/gcc/testsuite/g++.dg/gomp/pr66571-1.C
new file mode 100644
index 0000000..9fa9ab6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr66571-1.C
@@ -0,0 +1,37 @@
+// PR c++/66571
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T, typename U>
+extern void bar (T, T, U);
+
+template <typename T, typename U>
+void
+foo (T a, T b, U c)
+{
+ #pragma omp parallel for simd shared (a, c) reduction (+:b)
+ for (int i = 0; i < 10; i++)
+ bar<T> (a, b, c);
+ #pragma omp target map(tofrom:a, c[0:5])
+ ;
+ #pragma omp task depend(inout:c[4:2])
+ ;
+ T d = a;
+ T e = b;
+ U f = c;
+ #pragma omp parallel for simd shared (d, f) reduction (+:e)
+ for (int i = 0; i < 10; i++)
+ bar<T> (d, e, f);
+ #pragma omp target map(tofrom:d, f[0:5])
+ ;
+ #pragma omp task depend(inout:f[4:2])
+ ;
+}
+
+void
+baz ()
+{
+ int a = 0, b = 0, cb[10] = {}, *c = cb;
+ foo <int, int *> (a, b, c);
+ foo <int &, int *&> (a, b, c);
+}