]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/g++.dg/gomp/tpl-atomic-2.C
* builtin-types.def (BT_FN_VOID_BOOL, BT_FN_VOID_SIZE_SIZE_PTR,
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / gomp / tpl-atomic-2.C
CommitLineData
8487df40 1// { dg-do compile }
2
3struct S { int x; } s;
4
5// Make sure we detect errors on non-type-dependent things
6// even when the templates are never instantiated.
7template<typename T> void f1()
8{
7e5a76c8 9 #pragma omp atomic // { dg-error "invalid" }
10 s += 1;
8487df40 11}
12
13template<typename T> void f2(float *f)
14{
7e5a76c8 15 #pragma omp atomic // { dg-error "invalid" }
16 *f |= 1; // { dg-error "evaluation" }
8487df40 17}
18
19// Here the rhs is dependent, but not type dependent.
8487df40 20template<typename T> void f3(float *f)
21{
7e5a76c8 22 #pragma omp atomic // { dg-error "invalid" }
23 *f |= sizeof (T); // { dg-error "evaluation" }
8487df40 24}
25
26// And the converse, no error here because we're never fed a T.
27template<typename T> void f4(T *t)
28{
29 #pragma omp atomic
30 *t += 1;
31}
32
33// Here we'll let it go, because the rhs is type dependent and
34// we can't properly instantiate the statement, and we do most
35// of the semantic analysis concurrent with that.
36template<typename T> void f5(float *f)
37{
7e5a76c8 38 #pragma omp atomic // { dg-error "invalid" "" { xfail *-*-* } }
39 *f |= (T)sizeof(T); // { dg-error "evaluation" "" { xfail *-*-* } }
8487df40 40}