e02a048f46
PR c++/30703 * gimplify.c (gimplify_scan_omp_clauses): Remove special casing of INDIRECT_REF <RESULT_DECL>. * cp-gimplify.c (cp_genericize_r): Don't dereference invisiref parameters and result decls in omp clauses. (cxx_omp_privatize_by_reference): Pass also invisiref PARM_DECLs by reference. * testsuite/libgomp.c++/pr30703.C: New test. From-SVN: r121688
74 lines
819 B
C
74 lines
819 B
C
// PR c++/30703
|
|
// { dg-do run }
|
|
|
|
#include <omp.h>
|
|
|
|
extern "C" void abort ();
|
|
|
|
int ctor, cctor, dtor;
|
|
|
|
struct A
|
|
{
|
|
A();
|
|
A(const A &);
|
|
~A();
|
|
int i;
|
|
};
|
|
|
|
A::A()
|
|
{
|
|
#pragma omp atomic
|
|
ctor++;
|
|
}
|
|
|
|
A::A(const A &r)
|
|
{
|
|
i = r.i;
|
|
#pragma omp atomic
|
|
cctor++;
|
|
}
|
|
|
|
A::~A()
|
|
{
|
|
#pragma omp atomic
|
|
dtor++;
|
|
}
|
|
|
|
void
|
|
foo (A a, A b)
|
|
{
|
|
int i, j = 0;
|
|
#pragma omp parallel for firstprivate (a) lastprivate (a) private (b) schedule (static, 1) num_threads (5)
|
|
for (i = 0; i < 5; i++)
|
|
{
|
|
b.i = 5;
|
|
if (a.i != 6)
|
|
#pragma omp atomic
|
|
j += 1;
|
|
a.i = b.i + i + 6;
|
|
}
|
|
|
|
if (j || a.i != 15)
|
|
abort ();
|
|
}
|
|
|
|
void
|
|
bar ()
|
|
{
|
|
A a, b;
|
|
a.i = 6;
|
|
b.i = 7;
|
|
foo (a, b);
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
omp_set_dynamic (false);
|
|
if (ctor || cctor || dtor)
|
|
abort ();
|
|
bar ();
|
|
if (ctor + cctor != dtor)
|
|
abort ();
|
|
}
|