@@ -4624,6 +4624,7 @@ omp_reduction_lookup (location_t loc, tre
TREE_OPERAND (id, 1),
type),
false, false);
+ tree fns = id;
if (id && is_overloaded_fn (id))
id = get_fns (id);
for (; id; id = OVL_NEXT (id))
@@ -4647,6 +4648,9 @@ omp_reduction_lookup (location_t loc, tre
return id;
}
}
+ if (id && BASELINK_P (fns))
+ perform_or_defer_access_check (BASELINK_BINFO (fns), id, id,
+ tf_warning_or_error);
return id;
}
@@ -0,0 +1,41 @@
+// { dg-do compile }
+
+struct S
+{
+ int s;
+ S () : s (0) {}
+private:
+ #pragma omp declare reduction (+:S:omp_out.s += omp_in.s) // { dg-error "is private" }
+protected:
+ #pragma omp declare reduction (-:S:omp_out.s += omp_in.s) // { dg-error "is protected" }
+};
+
+struct T : public S
+{
+ void foo ()
+ {
+ S s;
+ #pragma omp parallel reduction (S::operator +:s) // { dg-error "within this context" }
+ s.s = 1;
+ S t;
+ #pragma omp parallel reduction (S::operator -:t)
+ t.s = 1;
+ S u;
+ #pragma omp parallel reduction (+:u) // { dg-error "within this context" }
+ u.s = 1;
+ S v;
+ #pragma omp parallel reduction (-:v)
+ v.s = 1;
+ }
+};
+
+void
+foo ()
+{
+ S s;
+ #pragma omp parallel reduction (S::operator +:s) // { dg-error "within this context" }
+ s.s = 1;
+ S t;
+ #pragma omp parallel reduction (S::operator -:t) // { dg-error "within this context" }
+ t.s = 1;
+}