gcc/libgomp/testsuite/libgomp.c++/atomic-1.C
Jakub Jelinek 239371f9c7 re PR c++/33894 (pragma omp atomic broken)
PR c++/33894
	* cp-tree.h: Update comment - TYPE_LANG_FLAG_0 is not
	OMP_ATOMIC_DEPENDENT_P in OMP_ATOMIC.
	* pt.c (tsubst_expr): Assert OMP_ATOMIC_DEPENDENT_P.
	* semantics.c (finish_omp_atomic): Revert most of the
	2007-02-05 changes, just keep the new representation of
	OMP_ATOMIC_DEPENDENT_P OMP_ATOMIC.

	* testsuite/libgomp.c++/atomic-1.C: New test.

From-SVN: r129919
2007-11-06 09:26:50 +01:00

54 lines
766 B
C

// PR c++/33894
// { dg-do run }
// { dg-options "-O2" }
extern "C" void abort ();
int check;
template<typename T> void
foo ()
{
#pragma omp atomic
check |= sizeof (T);
}
template<typename T> void
bar (T *x, T y)
{
#pragma omp atomic
*x += y;
}
template<typename T> void
baz ()
{
#pragma omp atomic
check++;
}
int
main ()
{
int i = 0;
long l = 0;
check = 0;
foo<char> ();
if (check != sizeof (char))
abort ();
foo<short> ();
if (check != (sizeof (char) | sizeof (short)))
abort ();
bar(&i, 4);
bar(&l, 8L);
if (i != 4 || l != 8L)
abort ();
baz<char> ();
if (check != (sizeof (char) | sizeof (short)) + 1)
abort ();
baz<long double> ();
if (check != (sizeof (char) | sizeof (short)) + 2)
abort ();
}