diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/gomp | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/gomp')
164 files changed, 4694 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/gomp/atomic-1.C b/gcc/testsuite/g++.dg/gomp/atomic-1.C new file mode 100644 index 000000000..3e4bc569b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-1.C @@ -0,0 +1,99 @@ +/* { dg-do compile } */ + +int x; +volatile int y; +volatile unsigned char z; + +void f1(void) +{ + #pragma omp atomic + x++; + #pragma omp atomic + x--; + #pragma omp atomic + ++x; + #pragma omp atomic + --x; + #pragma omp atomic + x += 1; + #pragma omp atomic + x -= y; + #pragma omp atomic + x |= 1; + #pragma omp atomic + x &= 1; + #pragma omp atomic + x ^= 1; + #pragma omp atomic + x *= 3; + #pragma omp atomic + x /= 3; + #pragma omp atomic + x /= 3; + #pragma omp atomic + x <<= 3; + #pragma omp atomic + x >>= 3; +} + +void f2(void) +{ + #pragma omp atomic + y++; + #pragma omp atomic + y--; + #pragma omp atomic + ++y; + #pragma omp atomic + --y; + #pragma omp atomic + y += 1; + #pragma omp atomic + y -= x; + #pragma omp atomic + y |= 1; + #pragma omp atomic + y &= 1; + #pragma omp atomic + y ^= 1; + #pragma omp atomic + y *= 3; + #pragma omp atomic + y /= 3; + #pragma omp atomic + y /= 3; + #pragma omp atomic + y <<= 3; + #pragma omp atomic + y >>= 3; +} + +void f3(void) +{ + #pragma omp atomic + z++; + #pragma omp atomic + z--; + #pragma omp atomic + ++z; + #pragma omp atomic + --z; + #pragma omp atomic + z += 1; + #pragma omp atomic + z |= 1; + #pragma omp atomic + z &= 1; + #pragma omp atomic + z ^= 1; + #pragma omp atomic + z *= 3; + #pragma omp atomic + z /= 3; + #pragma omp atomic + z /= 3; + #pragma omp atomic + z <<= 3; + #pragma omp atomic + z >>= 3; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-10.C b/gcc/testsuite/g++.dg/gomp/atomic-10.C new file mode 100644 index 000000000..fe64f0f06 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-10.C @@ -0,0 +1,24 @@ +// PR middle-end/28046 +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-ompexp" } + +int a[3], b; +struct C { int x; int y; } c; + +int bar (void), *baz (void); + +void +foo (void) +{ +#pragma omp atomic + a[2] += bar (); +#pragma omp atomic + b += bar (); +#pragma omp atomic + c.y += bar (); +#pragma omp atomic + *baz () += bar (); +} + +// { dg-final { scan-tree-dump-times "__sync_fetch_and_add" 4 "ompexp" { target i?86-*-* x86_64-*-* ia64-*-* powerpc*-*-* alpha*-*-* } } } +// { dg-final { cleanup-tree-dump "ompexp" } } diff --git a/gcc/testsuite/g++.dg/gomp/atomic-11.C b/gcc/testsuite/g++.dg/gomp/atomic-11.C new file mode 100644 index 000000000..618c4c8e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-11.C @@ -0,0 +1,306 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#ifdef __cplusplus +bool atomicvar, c; +#else +_Bool atomicvar, c; +#endif +int i, atomicvar2, c2; + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar |= c; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= c; + #pragma omp barrier + #pragma omp atomic + atomicvar &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar &= c; + #pragma omp barrier + #pragma omp atomic + atomicvar += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar += c; + #pragma omp barrier + #pragma omp atomic + atomicvar -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar -= c; + #pragma omp barrier + #pragma omp atomic + atomicvar *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar *= c; + #pragma omp barrier + #pragma omp atomic + atomicvar /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar /= c; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar; + #pragma omp barrier +#ifndef __cplusplus + #pragma omp atomic + atomicvar--; + #pragma omp barrier + #pragma omp atomic + --atomicvar; + #pragma omp barrier +#endif + return 0; +} + +int +bar (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar2; + #pragma omp barrier + #pragma omp atomic + atomicvar2--; + #pragma omp barrier + #pragma omp atomic + --atomicvar2; + #pragma omp barrier + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-12.C b/gcc/testsuite/g++.dg/gomp/atomic-12.C new file mode 100644 index 000000000..6c1f96502 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-12.C @@ -0,0 +1,9 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#include "atomic-11.C" diff --git a/gcc/testsuite/g++.dg/gomp/atomic-13.C b/gcc/testsuite/g++.dg/gomp/atomic-13.C new file mode 100644 index 000000000..f8fc9d872 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-13.C @@ -0,0 +1,43 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +#ifdef __cplusplus +bool *baz (); +#else +_Bool *baz (); +#endif +int *bar (); + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + (*bar ())++; + #pragma omp barrier + #pragma omp atomic + ++(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*bar ())--; + #pragma omp barrier + #pragma omp atomic + --(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*baz ())++; + #pragma omp barrier + #pragma omp atomic + ++(*baz ()); +#ifndef __cplusplus + #pragma omp barrier + #pragma omp atomic + (*baz ())--; + #pragma omp barrier + #pragma omp atomic + --(*baz ()); + #pragma omp barrier +#endif + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-14.C b/gcc/testsuite/g++.dg/gomp/atomic-14.C new file mode 100644 index 000000000..ae1eb50dc --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-14.C @@ -0,0 +1,19 @@ +// PR middle-end/45423 +// { dg-do compile } +// { dg-options "-fopenmp" } + +bool *baz (), atomicvar; + +int +foo (void) +{ + #pragma omp atomic + (*baz ())--; // { dg-error "invalid use of Boolean" } + #pragma omp atomic + --(*baz ()); // { dg-error "invalid use of Boolean" } + #pragma omp atomic + atomicvar--; // { dg-error "invalid use of Boolean" } + #pragma omp atomic + --atomicvar; // { dg-error "invalid use of Boolean" } + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-2.C b/gcc/testsuite/g++.dg/gomp/atomic-2.C new file mode 100644 index 000000000..720ec9e8b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-2.C @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +float x, y; + +void f1(void) +{ + #pragma omp atomic + x++; + #pragma omp atomic + x--; + #pragma omp atomic + ++x; + #pragma omp atomic + --x; + #pragma omp atomic + x += 1; + #pragma omp atomic + x -= y; + #pragma omp atomic + x *= 3; + #pragma omp atomic + x /= 3; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-3.C b/gcc/testsuite/g++.dg/gomp/atomic-3.C new file mode 100644 index 000000000..7ea792d34 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-3.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +int *xyzzy; + +void f1(void) +{ + #pragma omp atomic + xyzzy++; +} + +/* { dg-final { scan-tree-dump-times "xyzzy, 4" 1 "ompexp" { target i?86-*-* x86_64-*-* ia64-*-* powerpc*-*-* alpha*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/atomic-4.C b/gcc/testsuite/g++.dg/gomp/atomic-4.C new file mode 100644 index 000000000..7f27370d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-4.C @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +int a[4]; +int *p; +struct S { int x; int y[4]; } s; +int *bar(void); + +void f1(void) +{ + #pragma omp atomic + a[4] += 1; + #pragma omp atomic + *p += 1; + #pragma omp atomic + s.x += 1; + #pragma omp atomic + s.y[*p] += 1; + #pragma omp atomic + s.y[*p] *= 42; + #pragma omp atomic + *bar() += 1; + #pragma omp atomic + *bar() *= 42; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-5.C b/gcc/testsuite/g++.dg/gomp/atomic-5.C new file mode 100644 index 000000000..0f750c73d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-5.C @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +int x; +const int y = 0; +int bar(void); + +void f1(void) +{ + #pragma omp atomic + x %= 2; /* { dg-error "invalid operator" } */ + #pragma omp atomic + x = x + 1; /* { dg-error "invalid operator" } */ + #pragma omp atomic + x = 1; /* { dg-error "invalid operator" } */ + #pragma omp atomic + ++y; /* { dg-error "read-only variable" } */ + #pragma omp atomic + y--; /* { dg-error "read-only variable" } */ + #pragma omp atomic + y += 1; /* { dg-error "read-only variable" } */ + #pragma omp atomic + bar(); /* { dg-error "invalid operator" } */ + #pragma omp atomic + bar() += 1; /* { dg-error "lvalue required" } */ + #pragma omp atomic a /* { dg-error "expected end of line" } */ + x++; + #pragma omp atomic + ; /* { dg-error "expected primary-expression" } */ + #pragma omp atomic + #pragma omp atomic /* { dg-error "not allowed" } */ + ; + /* Check that we didn't get stuck on the pragma eol marker. */ + undef; /* { dg-error "" } */ +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-6.C b/gcc/testsuite/g++.dg/gomp/atomic-6.C new file mode 100644 index 000000000..52ac40f2a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-6.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-w -fopenmp" } + +int x[10], z; +double y[10]; + +void f1(void) +{ + #pragma omp atomic + x[z] /= y[z]; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-7.C b/gcc/testsuite/g++.dg/gomp/atomic-7.C new file mode 100644 index 000000000..612e97f45 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-7.C @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +double x, y; + +void f2(void) +{ + #pragma omp atomic + y++; + #pragma omp atomic + y--; + #pragma omp atomic + ++y; + #pragma omp atomic + --y; + #pragma omp atomic + y += 1; + #pragma omp atomic + y -= x; + #pragma omp atomic + y *= 3; + #pragma omp atomic + y /= 3; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-8.C b/gcc/testsuite/g++.dg/gomp/atomic-8.C new file mode 100644 index 000000000..2f04151f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-8.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +long double z; + +void f3(void) +{ + #pragma omp atomic + z++; + #pragma omp atomic + z--; + #pragma omp atomic + ++z; + #pragma omp atomic + --z; + #pragma omp atomic + z += 1; + #pragma omp atomic + z *= 3; + #pragma omp atomic + z /= 3; +} diff --git a/gcc/testsuite/g++.dg/gomp/atomic-9.C b/gcc/testsuite/g++.dg/gomp/atomic-9.C new file mode 100644 index 000000000..2fafbd409 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-9.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +volatile int *bar(void); + +void f1(void) +{ + #pragma omp atomic + *bar() += 1; +} + +/* { dg-final { scan-tree-dump-times "__sync_fetch_and_add" 1 "ompexp" { target i?86-*-* x86_64-*-* ia64-*-* powerpc*-*-* alpha*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/barrier-1.C b/gcc/testsuite/g++.dg/gomp/barrier-1.C new file mode 100644 index 000000000..10ca553f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/barrier-1.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple" } */ + +void f1(void) +{ + #pragma omp barrier +} + +void f2(bool p) +{ + if (p) + { + #pragma omp barrier + } +} + +/* { dg-final { scan-tree-dump-times "GOMP_barrier" 2 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/barrier-2.C b/gcc/testsuite/g++.dg/gomp/barrier-2.C new file mode 100644 index 000000000..1d929d26d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/barrier-2.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +void f1(void) +{ + #pragma omp barrier a // { dg-error "expected end of line" } +} + +void f3(bool p) +{ + if (p) + #pragma omp barrier // { dg-error "compound statements" } +} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/gomp/block-0.C b/gcc/testsuite/g++.dg/gomp/block-0.C new file mode 100644 index 000000000..fa7865d8b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-0.C @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-omplower" } + +void bar(); +void foo() +{ + #pragma omp critical + bar (); + #pragma omp master + bar (); + #pragma omp single + bar (); + #pragma omp for + for (int i = 0; i < 10; ++i) + bar (); + #pragma omp sections + { bar(); } + #pragma omp parallel + bar (); + #pragma omp parallel for + for (int i = 0; i < 10; ++i) + bar (); + #pragma omp parallel sections + { + bar (); + bar (); + #pragma omp section + bar (); + } +} + +// { dg-final { scan-tree-dump-times "terminate" 10 "omplower" } } +// { dg-final { cleanup-tree-dump "omplower" } } diff --git a/gcc/testsuite/g++.dg/gomp/block-1.C b/gcc/testsuite/g++.dg/gomp/block-1.C new file mode 100644 index 000000000..d2b86645a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-1.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +void foo() +{ + bad1: // { dg-error "jump to label" } + #pragma omp parallel + goto bad1; // { dg-error "from here|exits OpenMP" } + + goto bad2; // { dg-error "from here" } + #pragma omp parallel + { + bad2: ; // { dg-error "jump to label|enters OpenMP" } + } + + #pragma omp parallel + { + int i; + goto ok1; + for (i = 0; i < 10; ++i) + { ok1: break; } + } +} + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/gomp/block-10.C b/gcc/testsuite/g++.dg/gomp/block-10.C new file mode 100644 index 000000000..b273c1f29 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-10.C @@ -0,0 +1,40 @@ +// { dg-do compile } + +void foo(int i) +{ + int j; + switch (i) + { + #pragma omp parallel + { case 0:; } // { dg-error "jump|enters" } + } + switch (i) + { + #pragma omp for + for (j = 0; j < 10; ++ j) + { case 1:; } // { dg-error "jump|enters" } + } + switch (i) + { + #pragma omp critical + { case 2:; } // { dg-error "jump|enters" } + } + switch (i) + { + #pragma omp master + { case 3:; } // { dg-error "jump|enters" } + } + switch (i) + { + #pragma omp sections + { case 4:; // { dg-error "jump|enters" } + #pragma omp section + { case 5:; } // { dg-error "jump|enters" } + } + } + switch (i) + { + #pragma omp ordered + { default:; } // { dg-error "jump|enters" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-11.C b/gcc/testsuite/g++.dg/gomp/block-11.C new file mode 100644 index 000000000..c2800061b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-11.C @@ -0,0 +1,19 @@ +/* PR c++/24516 */ +/* { dg-do compile } */ + +void +bar (int *p) +{ + int m; +#pragma omp parallel for + for (m = 0; m < 1000; ++m) + switch (p[m]) + { + case 1: + p[m] = 2; + break; + default: + p[m] = 3; + break; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-2.C b/gcc/testsuite/g++.dg/gomp/block-2.C new file mode 100644 index 000000000..17d98d845 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-2.C @@ -0,0 +1,35 @@ +// { dg-do compile } + +void foo() +{ + int i, j; + + #pragma omp for + for (i = 0; i < 10; ++i) + break; // { dg-error "break" } + + bad1: // { dg-error "jump to label" } + #pragma omp for + for (i = 0; i < 10; ++i) + goto bad1; // { dg-error "from here|exits OpenMP" } + + goto bad2; // { dg-error "from here" } + #pragma omp for + for (i = 0; i < 10; ++i) + { + bad2: ; // { dg-error "jump|enters OpenMP" } + } + + #pragma omp for + for (i = 0; i < 10; ++i) + for (j = 0; j < 10; ++j) + if (i == j) + break; + + #pragma omp for + for (i = 0; i < 10; ++i) + continue; +} + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 14 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 16 } diff --git a/gcc/testsuite/g++.dg/gomp/block-3.C b/gcc/testsuite/g++.dg/gomp/block-3.C new file mode 100644 index 000000000..aeb0c7795 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-3.C @@ -0,0 +1,61 @@ +// { dg-do compile } + +extern int test(int); +void foo() +{ + int i; + + for (i = 0; i < 10; ++i) + { + #pragma omp sections + { + continue; // { dg-error "invalid exit" } + } + } + + #pragma omp sections + { + #pragma omp section + { bad1: ; } // { dg-error "jump to label" } + #pragma omp section + goto bad1; // { dg-error "from here|enters OpenMP" } + } + + #pragma omp sections + { + goto bad2; // { dg-error "from here" } + } + bad2:; // { dg-error "jump|exits OpenMP" } + + goto bad3; // { dg-error "from here" } + #pragma omp sections + { + bad3: ; // { dg-error "jump|enters OpenMP" } + } + + #pragma omp sections + { + goto ok1; + ok1:; + + #pragma omp section + for (i = 0; i < 10; ++i) + if (test(i)) + break; + else + continue; + + #pragma omp section + switch (i) + { + case 0: + break; + default: + test(i); + } + } +} + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 21 } +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 26 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 30 } diff --git a/gcc/testsuite/g++.dg/gomp/block-4.C b/gcc/testsuite/g++.dg/gomp/block-4.C new file mode 100644 index 000000000..815d36b2e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-4.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +void foo() +{ + #pragma omp critical + { + return; // { dg-error "invalid exit" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-5.C b/gcc/testsuite/g++.dg/gomp/block-5.C new file mode 100644 index 000000000..391f8b660 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-5.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +void foo() +{ + #pragma omp master + { + goto bad1; // { dg-error "from here" } + } + + #pragma omp master + { + bad1: // { dg-error "jump|exits OpenMP" } + return; // { dg-error "invalid exit" } + } +} + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/gomp/block-6.C b/gcc/testsuite/g++.dg/gomp/block-6.C new file mode 100644 index 000000000..fa4c5eab5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-6.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +void foo() +{ + #pragma omp ordered + { + return; // { dg-error "invalid exit" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-7.C b/gcc/testsuite/g++.dg/gomp/block-7.C new file mode 100644 index 000000000..802b3b3a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-7.C @@ -0,0 +1,20 @@ +// { dg-do compile } + +void foo() +{ + int i, j; + for (i = 0; i < 10; ++i) + { + #pragma omp for + for (j = ({ continue; 0; }); // { dg-error "invalid exit" } + j < ({ continue; 10; }); // { dg-error "invalid exit" } + j += ({ continue; 1; })) // { dg-error "invalid exit" } + continue; + + #pragma omp for + for (j = ({ break; 0; }); // { dg-error "invalid exit" } + j < ({ break; 10; }); // { dg-error "invalid exit" } + j += ({ break; 1; })) // { dg-error "invalid exit" } + break; // { dg-error "break" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-8.C b/gcc/testsuite/g++.dg/gomp/block-8.C new file mode 100644 index 000000000..177acaa28 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-8.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// PR 24451 + +int foo() +{ + int i; + + #pragma omp parallel for + for (i = 0; i < 10; ++i) + return 0; // { dg-error "invalid exit" } +} diff --git a/gcc/testsuite/g++.dg/gomp/block-9.C b/gcc/testsuite/g++.dg/gomp/block-9.C new file mode 100644 index 000000000..8012e5a7d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/block-9.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +void foo(int i) +{ + int j; + switch (i) + { + #pragma omp parallel + { case 0:; } // { dg-error "jump|enters" } + #pragma omp for + for (j = 0; j < 10; ++ j) + { case 1:; } // { dg-error "jump|enters" } + #pragma omp critical + { case 2:; } // { dg-error "jump|enters" } + #pragma omp master + { case 3:; } // { dg-error "jump|enters" } + #pragma omp sections + { case 4:; // { dg-error "jump|enters" } + #pragma omp section + { case 5:; } // { dg-error "jump|enters" } + } + #pragma omp ordered + { default:; } // { dg-error "jump|enters" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/clause-1.C b/gcc/testsuite/g++.dg/gomp/clause-1.C new file mode 100644 index 000000000..76683ecf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/clause-1.C @@ -0,0 +1,32 @@ +// { dg-do compile } + +struct T +{ + int n; + + void test(); +}; + +void T::test() +{ + #pragma omp parallel private(n) // { dg-error "T::n" } + n = 1; + + #pragma omp parallel shared(n) // { dg-error "T::n" } + n = 1; + + #pragma omp parallel firstprivate(n) // { dg-error "T::n" } + n = 1; + + #pragma omp sections lastprivate(n) // { dg-error "T::n" } + { n = 1; } + + #pragma omp parallel reduction(+:n) // { dg-error "T::n" } + n = 1; + + #pragma omp single copyprivate(n) // { dg-error "T::n" } + n = 1; + + #pragma omp parallel copyin(n) // { dg-error "T::n" } + n = 1; +} diff --git a/gcc/testsuite/g++.dg/gomp/clause-2.C b/gcc/testsuite/g++.dg/gomp/clause-2.C new file mode 100644 index 000000000..450419ad6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/clause-2.C @@ -0,0 +1,38 @@ +// { dg-do compile } + +struct A { int a; }; +struct B { B(); }; +struct C { C(); C(const C&); }; +struct D { D& operator=(const D&); }; + +class E { private: E(); public: E(int); }; // { dg-error "private" } +class F { private: F(const F&); public: F(); }; // { dg-error "private" } +class G { private: G& operator=(const G&); }; // { dg-error "private" } + +void bar(); +void foo() +{ + A a; B b; C c; D d; E e(0); F f; G g; + + #pragma omp parallel shared(a, b, c, d, e, f, g) + bar(); + + #pragma omp parallel private(a, b, c, d, f, g) + bar(); + #pragma omp parallel private(e) // { dg-error "context" } + bar(); + + #pragma omp parallel firstprivate(a, b, c, d, e, g) + bar(); + #pragma omp parallel firstprivate(f) // { dg-error "context" } + bar(); + + #pragma omp parallel sections lastprivate(a, b, d, c, f) + { bar(); } + #pragma omp parallel sections lastprivate(e) // { dg-error "context" } + { bar(); } + #pragma omp parallel sections lastprivate(g) // { dg-error "context" } + { bar(); } + #pragma omp parallel sections firstprivate(e) lastprivate(e) + { bar(); } +} diff --git a/gcc/testsuite/g++.dg/gomp/clause-3.C b/gcc/testsuite/g++.dg/gomp/clause-3.C new file mode 100644 index 000000000..6b3d410a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/clause-3.C @@ -0,0 +1,94 @@ +// { dg-do compile } +// { dg-require-effective-target tls } + +#define p parallel + +extern void bar (void); +extern char q[]; // { dg-error "has incomplete type" } +int t; +#pragma omp threadprivate (t) + +void +foo (int x) +{ + char *p; + struct S { int i; int j; } s; + char a[32]; + double d; + int i; + const int c = 8; +#pragma omp p shared (x, x) // { dg-error "more than once" } + ; +#pragma omp p private (x) private (x) // { dg-error "more than once" } + ; +#pragma omp p shared (x) firstprivate (x) // { dg-error "more than once" } + ; +#pragma omp p firstprivate (x, x) // { dg-error "more than once" } + ; +#pragma omp p for shared (x) lastprivate (x) // { dg-error "more than once" } + for (i = 0; i < 10; i++) + ; +#pragma omp p for private (x) lastprivate (x) // { dg-error "more than once" } + for (i = 0; i < 10; i++) + ; +#pragma omp p for lastprivate (x, x) // { dg-error "more than once" } + for (i = 0; i < 10; i++) + ; +#pragma omp single private (x) copyprivate (x) // { dg-error "more than once" } + ; +#pragma omp p shared (bar) // { dg-error "is not a variable" } + ; +#pragma omp p private (bar) // { dg-error "is not a variable" } + ; +#pragma omp p firstprivate (bar) // { dg-error "is not a variable" } + ; +#pragma omp p reduction (+:p) // { dg-error "has invalid type for" } + ; +#pragma omp p reduction (*:s) // { dg-error "has invalid type for" } + ; +#pragma omp p reduction (-:a) // { dg-error "has invalid type for" } + ; + d = 0; +#pragma omp p reduction (*:d) + ; +#pragma omp p reduction (|:d) // { dg-error "has invalid type for" } + ; +#pragma omp p reduction (&&:d) // { dg-error "has invalid type for" } + ; +#pragma omp p copyin (d) // { dg-error "must be 'threadprivate'" } + ; +#pragma omp p copyin (x) // { dg-error "must be 'threadprivate'" } + ; +#pragma omp p for firstprivate (x) lastprivate (x) + for (i = 0; i < 10; i++) + ; +#pragma omp p private (q) // { dg-error "unspecified bounds" } + ; +#pragma omp p firstprivate (q) // { dg-error "unspecified bounds" } + ; +#pragma omp p for lastprivate (q) // { dg-error "unspecified bounds" } + for (i = 0; i < 10; i++) + ; +#pragma omp p shared (t) // { dg-error "predetermined 'threadprivate'" } + ; +#pragma omp p private (t) // { dg-error "predetermined 'threadprivate'" } + ; +#pragma omp p firstprivate (t) // { dg-error "predetermined 'threadprivate'" } + ; +#pragma omp p for lastprivate (t) // { dg-error "predetermined 'threadpriv" } + for (i = 0; i < 10; i++) + ; +#pragma omp p reduction (*:t) // { dg-error "predetermined 'threadprivate'" } + ; +#pragma omp p shared (c) // { dg-error "predetermined 'shared'" } + ; +#pragma omp p private (c) // { dg-error "predetermined 'shared'" } + ; +#pragma omp p firstprivate (c) // { dg-error "predetermined 'shared'" } + ; +#pragma omp p for lastprivate (c) // { dg-error "predetermined 'shared'" } + for (i = 0; i < 10; i++) + ; +#pragma omp p reduction (*:c) // { dg-error "predetermined 'shared'" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/clause-4.C b/gcc/testsuite/g++.dg/gomp/clause-4.C new file mode 100644 index 000000000..06b91e8a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/clause-4.C @@ -0,0 +1,23 @@ +// PR c/34506 +// { dg-do compile } + +#define p parallel + +void +foo (int x) +{ +#pragma omp p num_threads (4) if (1) private (x) + ; +#pragma omp p num_threads(4)if(1)private(x) + ; +#pragma omp p num_threads (4), if (1) , private (x) + ; +#pragma omp p num_threads(4),if(1),private(x) + ; +#pragma omp p, num_threads (4), if (1), private (x) // { dg-error "clause before" } + ; +#pragma omp p num_threads (4), if (1), private (x), // { dg-error "clause before" } + ; +#pragma omp p num_threads (4), , if (1), private (x) // { dg-error "clause before" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/copyin-1.C b/gcc/testsuite/g++.dg/gomp/copyin-1.C new file mode 100644 index 000000000..117f82f81 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/copyin-1.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-require-effective-target tls } + +int i, j; + +#pragma omp threadprivate (i) + +void bar(void); +void foo(void) +{ + int k; + extern int l; + extern int m; + +#pragma omp threadprivate (m) + + #pragma omp parallel copyin(i) + bar(); + #pragma omp parallel copyin(j) // { dg-error "threadprivate" } + bar(); + #pragma omp parallel copyin(k) // { dg-error "threadprivate" } + bar(); + #pragma omp parallel copyin(l) // { dg-error "threadprivate" } + bar(); + #pragma omp parallel copyin(m) + bar(); +} diff --git a/gcc/testsuite/g++.dg/gomp/critical-1.C b/gcc/testsuite/g++.dg/gomp/critical-1.C new file mode 100644 index 000000000..bdc7bad7b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/critical-1.C @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-omplower" } */ + +extern void bar(int); + +void foo (void) +{ + #pragma omp critical + bar(0); + + /* Note that "name" is in its own namespace, thus this foo is not + the same as the function. */ + #pragma omp critical(foo) + { + bar(1); + bar(2); + } + + #pragma omp critical + #pragma omp critical(foo) + bar(3); +} + +/* { dg-final { scan-tree-dump-times "GOMP_critical_start" 2 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_critical_end" 2 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_critical_name_start" 2 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_critical_name_end" 2 "omplower" } } */ +/* { dg-final { cleanup-tree-dump "omplower" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/critical-2.C b/gcc/testsuite/g++.dg/gomp/critical-2.C new file mode 100644 index 000000000..37c9c2414 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/critical-2.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +void f1(void) +{ + #pragma omp critical a // { dg-error "expected" } + ; + #pragma omp critical ( // { dg-error "expected identifier" } + ; + #pragma omp critical (a // { dg-error "expected .\\)." } + ; + #pragma omp critical (a b) // { dg-error "expected .\\)." } +} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/gomp/flush-1.C b/gcc/testsuite/g++.dg/gomp/flush-1.C new file mode 100644 index 000000000..3c6a34bff --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/flush-1.C @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple" } */ + +void f1(void) +{ + #pragma omp flush +} + +int x; + +void f2(bool p) +{ + int z; + if (p) + { + #pragma omp flush (x) + } + else + { + #pragma omp flush (x, z, p) + } +} + +/* { dg-final { scan-tree-dump-times "__sync_synchronize" 3 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/flush-2.C b/gcc/testsuite/g++.dg/gomp/flush-2.C new file mode 100644 index 000000000..a5c0df89c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/flush-2.C @@ -0,0 +1,10 @@ +// { dg-do compile } + +void f1(void) +{ + #pragma omp flush a // { dg-error "expected" } + #pragma omp flush ( // { dg-error "expected" } + #pragma omp flush (b // { dg-error "declared|expected" } + #pragma omp flush (c d) // { dg-error "declared|expected" } + #pragma omp flush (e) // { dg-error "declared" } +} diff --git a/gcc/testsuite/g++.dg/gomp/for-1.C b/gcc/testsuite/g++.dg/gomp/for-1.C new file mode 100644 index 000000000..f8bb9d547 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-1.C @@ -0,0 +1,49 @@ +// { dg-do compile } + +extern void baz(int); +void foo (int j, int k) +{ + int i; + + /* Valid loops. */ + #pragma omp for + for (i = 0; i < 10; i++) + baz (i); + + #pragma omp for + for (i = j; i <= 10; i+=4) + baz (i); + + #pragma omp for + for (i = j; i > 0; i = i - 1) + baz (j); + + #pragma omp for + for (i = j; i >= k; i--) + baz (i); + + // Malformed parallel loops. + #pragma omp for + i = 0; // { dg-error "for statement expected" } + for ( ; i < 10; ) + { + baz (i); + i++; + } + + #pragma omp for + for (i = 0; ; i--) // { dg-error "missing controlling predicate" } + { + if (i >= 10) + break; // { dg-error "break" } + baz (i); + } + + #pragma omp for + for (i = 0; i < 10 && j > 4; i-=3) // { dg-error "invalid controlling predicate" } + baz (i); + + #pragma omp for + for (i = 0; i < 10; i-=3, j+=2) // { dg-error "invalid increment expression" } + baz (i); +} diff --git a/gcc/testsuite/g++.dg/gomp/for-10.C b/gcc/testsuite/g++.dg/gomp/for-10.C new file mode 100644 index 000000000..f21404249 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-10.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(runtime) ordered + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_runtime_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_runtime_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-11.C b/gcc/testsuite/g++.dg/gomp/for-11.C new file mode 100644 index 000000000..d15576d2f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-11.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +extern void baz (int); + +void foo (int j, int k) +{ + #pragma omp for + for (int l = j; l < k; l++) + baz (l); + + #pragma omp for + for (int i = 0, m = 0; m < 10; m++) // { dg-error "" } + baz (m); +} diff --git a/gcc/testsuite/g++.dg/gomp/for-12.C b/gcc/testsuite/g++.dg/gomp/for-12.C new file mode 100644 index 000000000..98318d7d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-12.C @@ -0,0 +1,12 @@ +int foo (void) +{ + int i, a; + + a = 30; + + #pragma omp parallel for lastprivate (a) + for (i = 0; i < 10; i++) + a = a + i; + + return a; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-13.C b/gcc/testsuite/g++.dg/gomp/for-13.C new file mode 100644 index 000000000..16e971f19 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-13.C @@ -0,0 +1,18 @@ +// At one point in development, a typo disabled the remapping of the +// for iteration variable as private. + +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-lower" } + +extern void bar(int); +void foo(void) +{ + int i; + +#pragma omp parallel for default(none) + for (i = 0; i < 10; i++) + bar(i); +} + +// { dg-final { scan-tree-dump-times "omp_data_o" 0 "lower" } } +// { dg-final { cleanup-tree-dump "lower" } } diff --git a/gcc/testsuite/g++.dg/gomp/for-14.C b/gcc/testsuite/g++.dg/gomp/for-14.C new file mode 100644 index 000000000..fb2641370 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-14.C @@ -0,0 +1,19 @@ +// { dg-do compile } + +extern int printf (const char *, ...); +extern void foo (int *); + +int main (void) +{ + double d = 6; + int i = 1, j = 6, k = 8; +#pragma omp parallel shared(d) private(i) num_threads (4) + { + i = 4; +#pragma omp for lastprivate(j) + for (j = 1; j <= k; j++) + printf ("%s %d %d %d %p %g\n", "Hello, World!", i, j, k, &j, d); + printf ("%s %d %g\n", "Hello, World!", i, d); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-15.C b/gcc/testsuite/g++.dg/gomp/for-15.C new file mode 100644 index 000000000..25eea2ad2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-15.C @@ -0,0 +1,35 @@ +// PR c++/24512 +// { dg-do compile } + +template<typename T> void foo () +{ +#pragma omp for + for (int i = 0; i < 10; i++); + +#pragma omp for + for (int i = 0; i < 10; i++); + +#pragma omp for + for (T j = 0; j < 10; j++); + +#pragma omp for + for (T j = 0; j < 10; j++); + +#pragma omp parallel for + for (int k = 0; k < 10; k++); + +#pragma omp parallel for + for (int k = 0; k < 10; k++); + +#pragma omp parallel for + for (T l = 0; l < 10; l++); + +#pragma omp parallel for + for (T l = 0; l < 10; l++); +} + +void bar () +{ + foo<int> (); + foo<long> (); +} diff --git a/gcc/testsuite/g++.dg/gomp/for-16.C b/gcc/testsuite/g++.dg/gomp/for-16.C new file mode 100644 index 000000000..dbbed8fe5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-16.C @@ -0,0 +1,32 @@ +// { dg-do compile } + +template<typename T> +void foo () +{ +#pragma omp for + for (unsigned int i = 0; i < 10; i++); +#pragma omp for + for (int j = 0; ; j++); // { dg-error "missing controlling predicate" } +#pragma omp for + for (int k = 0; k == 1; k++); // { dg-error "invalid controlling predicate" } +#pragma omp for + for (int l = 0; l < 10; ); // { dg-error "missing increment expression" } +#pragma omp for + for (int m = 0; m < 10; m *= 3); // { dg-error "invalid increment expression" } +#pragma omp for + for (T n = 0; ; n++); // { dg-error "missing controlling predicate" } +#pragma omp for + for (T o = 0; o == 1; o++); // Error here is emitted only during + // instantiation +#pragma omp for + for (T p = 0; p < 10; ); // { dg-error "missing increment expression" } +#pragma omp for + for (T q = 0; q < 10; q *= 3); // Error here is emitted only during + // instantiation +} + +void bar () +{ +#pragma omp for + for (int m = 0; m < 10; m *= 3); // { dg-error "invalid increment expression" } +} diff --git a/gcc/testsuite/g++.dg/gomp/for-17.C b/gcc/testsuite/g++.dg/gomp/for-17.C new file mode 100644 index 000000000..9634e59c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-17.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void foo() +{ + long n = 10; + int i; +#pragma omp for + for (i=0; i < n; ++i) ; +#pragma omp for + for (i=0; n > i; ++i) ; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-18.C b/gcc/testsuite/g++.dg/gomp/for-18.C new file mode 100644 index 000000000..0a5052674 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-18.C @@ -0,0 +1,67 @@ +// { dg-do compile } +extern int bar (int); + +void +foo (void) +{ + int j, k = 1, l = 30, m = 4; + long int o = 4; + long long int p = 0; +#pragma omp for + for (j = k; j <= l; j += m - 1) + ; +#pragma omp for + for (j = k; j <= l; j += (m - 1)) + ; +#pragma omp for + for (j = k; j <= l; j += bar (m - 1)) + ; +#pragma omp for + for (j = k; j <= l; j = j + m - 1) + ; +#pragma omp for + for (j = k; j <= l; j = j + (m - 1)) + ; +#pragma omp for + for (j = k; j <= l; j = j + bar (m - 1)) + ; +#pragma omp for + for (j = ({ int n; n = k; n; }); j <= l; j++) + ; +#pragma omp for + for (j = k; j <= ({ int n; n = l; n; }); j++) + ; +#pragma omp for + for (j = k; j <= l; j += ({ int n; n = 1; n; })) + ; +#pragma omp for + for (j = k; j <= l; j += m + 1) + ; +#pragma omp for + for (j = k; j <= l; j += o) + ; +#pragma omp for + for (j = k; j <= l; j = j + o) + ; +#pragma omp for + for (j = k; j <= l; j = o + 1 + j) + ; +#pragma omp for + for (j = k; j <= l; j = o + m + j) + ; +#pragma omp for + for (j = k; j <= l; j += o + p) + ; +#pragma omp for + for (j = k; j <= l; j = j + o + p) + ; +#pragma omp for + for (j = l; j >= k; j -= o) + ; +#pragma omp for + for (j = l; j >= k; j -= p) + ; +#pragma omp for + for (j = l; j >= k; j -= o + p) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C new file mode 100644 index 000000000..1929e45f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-19.C @@ -0,0 +1,41 @@ +// PR c++/38348 +// { dg-do compile } +// { dg-options "-fopenmp" } + +const char *p = "abcde"; + +template <typename T> +void +f1 (void) +{ +#pragma omp for // { dg-error "forbids incrementing a pointer of type" } + for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } + ; +} + +template <typename T> +void +f2 (void) +{ +#pragma omp for + for (const char *q = p; q < p + 4; q++) + ; +} + +template <typename T> +void +f3 (void) +{ +#pragma omp for // { dg-error "forbids incrementing a pointer of type" } + for (T q = T (p); q < T (p + 4); q++) + ; +} + +int +main (void) +{ + f1 <int> (); // { dg-message "instantiated from here" } + f2 <int> (); + f3 <const char *> (); + f3 <void *> (); // { dg-message "instantiated from here" } +} diff --git a/gcc/testsuite/g++.dg/gomp/for-2.C b/gcc/testsuite/g++.dg/gomp/for-2.C new file mode 100644 index 000000000..37e5929af --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-2.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +void foo() +{ + int i; + + #pragma omp for nowait + for (i = 0; i < 10; ++i) ; + + #pragma omp for nowait nowait /* { dg-error "too many" } */ + for (i = 0; i < 10; ++i) ; + + #pragma omp for ordered + for (i = 0; i < 10; ++i) ; + + #pragma omp for ordered ordered /* { dg-error "too many" } */ + for (i = 0; i < 10; ++i) ; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-3.C b/gcc/testsuite/g++.dg/gomp/for-3.C new file mode 100644 index 000000000..fcf5a2c1b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-3.C @@ -0,0 +1,62 @@ +// { dg-do compile } + +int bar (); + +void foo() +{ + int i; + + #pragma omp for schedule // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule static // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( // { dg-error "invalid schedule kind" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static ) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( foo ) // { dg-error "invalid schedule kind" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static 1 // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static 1 ) nowait // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static, 1 ) nowait + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static, 1, 1 ) nowait // { dg-error "expected" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static, 1 + 1 ) nowait + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule ( static, 1.0 ) // { dg-error "integral" } + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (dynamic) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (dynamic, bar ()) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (guided) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (guided, bar ()) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (runtime) + for (i = 0; i < 10; ++i) ; + + #pragma omp for schedule (runtime, bar ()) // { dg-error "does not take" } + for (i = 0; i < 10; ++i) ; +} diff --git a/gcc/testsuite/g++.dg/gomp/for-4.C b/gcc/testsuite/g++.dg/gomp/for-4.C new file mode 100644 index 000000000..fb6994ea2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-4.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(dynamic) + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_dynamic_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_dynamic_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-5.C b/gcc/testsuite/g++.dg/gomp/for-5.C new file mode 100644 index 000000000..5912a4e55 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-5.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(guided) + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_guided_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_guided_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-6.C b/gcc/testsuite/g++.dg/gomp/for-6.C new file mode 100644 index 000000000..100ee2c8c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-6.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(runtime) + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_runtime_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_runtime_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-7.C b/gcc/testsuite/g++.dg/gomp/for-7.C new file mode 100644 index 000000000..10763dc59 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-7.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(static) ordered + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_static_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_static_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-8.C b/gcc/testsuite/g++.dg/gomp/for-8.C new file mode 100644 index 000000000..1bc66c49a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-8.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(dynamic) ordered + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_dynamic_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_dynamic_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-9.C b/gcc/testsuite/g++.dg/gomp/for-9.C new file mode 100644 index 000000000..af99e216e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/for-9.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-ompexp" } */ + +extern void bar(int); + +void foo (int n) +{ + int i; + + #pragma omp for schedule(guided) ordered + for (i = 0; i < n; ++i) + bar(i); +} + +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_guided_start" 1 "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_loop_ordered_guided_next" 1 "ompexp" } } */ +/* { dg-final { cleanup-tree-dump "ompexp" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/gomp.exp b/gcc/testsuite/g++.dg/gomp/gomp.exp new file mode 100644 index 000000000..9f60bc1c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/gomp.exp @@ -0,0 +1,33 @@ +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib g++-dg.exp + +if ![check_effective_target_fopenmp] { + return +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "-fopenmp" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.dg/gomp/macro-1.C b/gcc/testsuite/g++.dg/gomp/macro-1.C new file mode 100644 index 000000000..b04610d2c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/macro-1.C @@ -0,0 +1,10 @@ +// { dg-do compile } + +#define N 10 + +extern void bar(void); +void foo(void) +{ + #pragma omp parallel num_threads(N) + bar(); +} diff --git a/gcc/testsuite/g++.dg/gomp/macro-2.C b/gcc/testsuite/g++.dg/gomp/macro-2.C new file mode 100644 index 000000000..75d6490cd --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/macro-2.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +#define p parallel +#define s(x) shared(x##1, x##2) +#define d(x) default(x) + +void bar(int, int, int, int); +void foo(void) +{ + int a1, a2, b1, b2; + + #pragma omp p s(a) s(b) d(none) + bar(a1, a2, b1, b2); +} diff --git a/gcc/testsuite/g++.dg/gomp/macro-3.C b/gcc/testsuite/g++.dg/gomp/macro-3.C new file mode 100644 index 000000000..3606db566 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/macro-3.C @@ -0,0 +1,26 @@ +// PR preprocessor/27746 +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-omplower" } + +#define omp FOO +#define p parallel +#define omp_parallel _Pragma ("omp parallel") +#define omp_p _Pragma ("omp p") + +void bar (void); + +void +foo (void) +{ + #pragma omp parallel + bar (); + #pragma omp p + bar (); + omp_parallel + bar (); + omp_p + bar (); +} + +// { dg-final { scan-tree-dump-times "#pragma omp parallel" 4 "omplower" } } +// { dg-final { cleanup-tree-dump "omplower" } } diff --git a/gcc/testsuite/g++.dg/gomp/macro-4.C b/gcc/testsuite/g++.dg/gomp/macro-4.C new file mode 100644 index 000000000..9fc45b143 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/macro-4.C @@ -0,0 +1,29 @@ +// PR preprocessor/27746 +// { dg-do compile } +// { dg-options "-fopenmp -Wunknown-pragmas" } + +#define p _Pragma ("omp parallel") +#define omp_p _Pragma ("omp p") + +void bar (void); + +void +foo (void) +{ +#pragma omp p // { dg-warning "ignoring #pragma omp _Pragma" } + bar (); + omp_p // { dg-warning "ignoring #pragma omp _Pragma" } + bar (); +} + +#define parallel serial +#define omp_parallel _Pragma ("omp parallel") + +void +baz (void) +{ +#pragma omp parallel // { dg-warning "ignoring #pragma omp serial" } + bar (); + omp_parallel // { dg-warning "ignoring #pragma omp serial" } + bar (); +} diff --git a/gcc/testsuite/g++.dg/gomp/master-1.C b/gcc/testsuite/g++.dg/gomp/master-1.C new file mode 100644 index 000000000..2681c216a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/master-1.C @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +extern void bar(int); + +void foo (void) +{ + #pragma omp master + bar(0); + + #pragma omp master + { + bar(1); + bar(2); + } + + /* Yes, this is legal -- structured-block contains statement contains + openmp-construct contains master-construct. */ + #pragma omp master + #pragma omp master + #pragma omp master + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/master-2.C b/gcc/testsuite/g++.dg/gomp/master-2.C new file mode 100644 index 000000000..053206627 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/master-2.C @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +void f1(void) +{ + #pragma omp master asdf /* { dg-error "expected" } */ + #pragma omp master +} /* { dg-error "expected" } */ diff --git a/gcc/testsuite/g++.dg/gomp/master-3.C b/gcc/testsuite/g++.dg/gomp/master-3.C new file mode 100644 index 000000000..37966106d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/master-3.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-omplower" } */ + +extern void bar(int); + +void foo (void) +{ + #pragma omp master + bar(0); +} + +/* { dg-final { scan-tree-dump-times "omp_get_thread_num" 1 "omplower" } } */ +/* { dg-final { cleanup-tree-dump "omplower" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/method-1.C b/gcc/testsuite/g++.dg/gomp/method-1.C new file mode 100644 index 000000000..3d8235656 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/method-1.C @@ -0,0 +1,18 @@ +/* PR c++/24513 */ +/* { dg-do compile } */ + +struct S +{ + void foo (int *p) + { +#pragma omp parallel for + for (int i = 0; i < 1000; ++i) + p[i]=0; + } + void bar () + { +#pragma omp master + j = 2; + } + int j; +}; diff --git a/gcc/testsuite/g++.dg/gomp/ordered-1.C b/gcc/testsuite/g++.dg/gomp/ordered-1.C new file mode 100644 index 000000000..a1cd7f486 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/ordered-1.C @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-omplower" } */ + +extern void bar(int); + +void foo (void) +{ + #pragma omp ordered + bar(0); + + #pragma omp ordered + { + bar(1); + bar(2); + } +} + +/* { dg-final { scan-tree-dump-times "GOMP_ordered_start" 2 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_ordered_end" 2 "omplower" } } */ +/* { dg-final { cleanup-tree-dump "omplower" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/ordered-2.C b/gcc/testsuite/g++.dg/gomp/ordered-2.C new file mode 100644 index 000000000..6c2b4329c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/ordered-2.C @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +void f1(void) +{ + #pragma omp ordered asdf /* { dg-error "expected" } */ + #pragma omp ordered +} /* { dg-error "expected" } */ diff --git a/gcc/testsuite/g++.dg/gomp/parallel-1.C b/gcc/testsuite/g++.dg/gomp/parallel-1.C new file mode 100644 index 000000000..c5c233b76 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/parallel-1.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +void foo() +{ + int i; + + #pragma omp parallel + { + #pragma omp parallel + { + #pragma omp parallel + { + i++; + } + } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/parallel-2.C b/gcc/testsuite/g++.dg/gomp/parallel-2.C new file mode 100644 index 000000000..68e577766 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/parallel-2.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +void foo() +{ + int i; + + #pragma omp parallel default(none) // { dg-error "enclosing" } + { + #pragma omp parallel + { + #pragma omp parallel default(none) // { dg-error "enclosing" } + { + i++; // { dg-error "not specified" } + } + } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/parallel-3.C b/gcc/testsuite/g++.dg/gomp/parallel-3.C new file mode 100644 index 000000000..633d7ba59 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/parallel-3.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +extern int printf (const char *, ...); + +int main (void) +{ + double d = 6; + int i = 1; +#pragma omp parallel shared(d) private(i) num_threads (4 + i) + { + i = 4; + printf ("%s %d %g\n", "Hello, World!", i, d); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/parallel-4.C b/gcc/testsuite/g++.dg/gomp/parallel-4.C new file mode 100644 index 000000000..ca06aeef9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/parallel-4.C @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +extern int foo(void); +extern void bar(void); + +int main () +{ + /* Malformed uses of 'if' and 'num_threads'. */ + #pragma omp parallel if (foo () > 10) if (foo () == 3) /* { dg-error "too many" } */ + { + bar (); + } + + #pragma omp parallel num_threads (3) num_threads (20) /* { dg-error "too many" } */ + { + bar (); + } + + /* Valid uses of 'if' and 'num_threads'. */ + #pragma omp parallel if (foo () == 10) num_threads (foo ()) + { + bar (); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/parallel-5.C b/gcc/testsuite/g++.dg/gomp/parallel-5.C new file mode 100644 index 000000000..b8cd174a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/parallel-5.C @@ -0,0 +1,11 @@ +// { dg-do compile } + +extern void bar (void); + +int main (void) +{ + int i; +#pragma omp parallel for nowait /* { dg-error "'nowait'" } */ + for (i = 0; i < 10; i++) + bar (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr24849.C b/gcc/testsuite/g++.dg/gomp/pr24849.C new file mode 100644 index 000000000..f35643719 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr24849.C @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +template<typename T> struct Healpix_Map { + T *map; + int npix_; + + void Import_nograde (const Healpix_Map<T> &orig) { +#pragma omp parallel +{ + int m; +#pragma omp for schedule (dynamic) + for (m=0; m<npix_; ++m) map[m] = orig.map[m]; +} + } + }; + +void foo(Healpix_Map<int> &a, Healpix_Map<int> &b) { + a.Import_nograde(b); + } diff --git a/gcc/testsuite/g++.dg/gomp/pr25874.C b/gcc/testsuite/g++.dg/gomp/pr25874.C new file mode 100644 index 000000000..83573f10a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr25874.C @@ -0,0 +1,25 @@ +// { dg-options "-O -fopenmp" } + +int foo(); + +struct wigner_d + { + void recurse () { + int dd; + for (int j=0; j<=1; ++j) { +#pragma omp parallel + dd=5; + } + } + }; + +template<typename T> void rotate_alm(T arg) + { + wigner_d rec; + rec.recurse(); +#pragma omp parallel + foo(); + } + +template void rotate_alm(float arg); +template void rotate_alm(double arg); diff --git a/gcc/testsuite/g++.dg/gomp/pr25996.C b/gcc/testsuite/g++.dg/gomp/pr25996.C new file mode 100644 index 000000000..6b50ff030 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr25996.C @@ -0,0 +1,32 @@ +// PR c/25996 + +void +test1 (void) +{ +#pragma omp for + for (i = 0; i < 1; ++i); // { dg-error "not declared|expected iteration decl" } +} + +void +test2 (void) +{ + int i; +#pragma omp for + for (i = j; i < 1; ++i); // { dg-error "not declared|expected iteration decl" } +} + +void +test3 (void) +{ + int i; +#pragma omp for + for (i = 0; i < j; ++i); // { dg-error "not declared|invalid controlling predicate" } +} + +void +test4 (void) +{ + int i; +#pragma omp for + for (i = 0; i < 10; i += j); // { dg-error "not declared|invalid increment expression" } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26611-1.C b/gcc/testsuite/g++.dg/gomp/pr26611-1.C new file mode 100644 index 000000000..8ec543bd6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26611-1.C @@ -0,0 +1,15 @@ +// PR middle-end/26611 +// { dg-do compile } + +void +foo () +{ +#pragma omp parallel + try + { + int q = 1; + } + catch (...) + { + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26611-2.C b/gcc/testsuite/g++.dg/gomp/pr26611-2.C new file mode 100644 index 000000000..f95179891 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26611-2.C @@ -0,0 +1,15 @@ +// PR middle-end/26611 +// { dg-do compile } + +void +foo () +{ +#pragma omp parallel + try + { + } + catch (...) + { + int q = 1; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26690-1.C b/gcc/testsuite/g++.dg/gomp/pr26690-1.C new file mode 100644 index 000000000..17e01b3d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26690-1.C @@ -0,0 +1,16 @@ +// PR c++/26690 +// { dg-do compile } + +struct A // { dg-message "A::A|candidate expects" } +{ + A (int); // { dg-message "note" } +}; + +void +foo () +{ + A a(0); +#pragma omp parallel private (a) // { dg-error "no matching function" } + // { dg-message "candidate" "candidate note" { target *-*-* } 13 } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26690-2.C b/gcc/testsuite/g++.dg/gomp/pr26690-2.C new file mode 100644 index 000000000..ca01a3a59 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26690-2.C @@ -0,0 +1,17 @@ +// PR c++/26690 +// { dg-do compile } + +struct A +{ + A (int x = 6); // { dg-message "A::A\\(int\\)" } + A (long long x = 12LL); // { dg-message "note" } +}; + +void +foo () +{ + A a(6); +#pragma omp parallel private (a) // { dg-error "call of overloaded" } + // { dg-message "candidate" "candidate note" { target *-*-* } 14 } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26823-1.C b/gcc/testsuite/g++.dg/gomp/pr26823-1.C new file mode 100644 index 000000000..d24eddbdf --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26823-1.C @@ -0,0 +1,23 @@ +// PR middle-end/26823 +// { dg-do compile } + +struct A +{ + ~A () {} +}; + +struct B +{ + A a; + B (); +}; + +void +foo () +{ +#pragma omp parallel + { + B b[1]; + new int; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26823-2.C b/gcc/testsuite/g++.dg/gomp/pr26823-2.C new file mode 100644 index 000000000..d4747cff5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26823-2.C @@ -0,0 +1,29 @@ +// PR middle-end/26823 +// { dg-do compile } + +struct A +{ + ~A () {} +}; + +extern void bar (); + +void +foo () +{ +#pragma omp parallel + { + { + A a; + bar (); + } + { + A a; + bar (); + } + { + A a; + bar (); + } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26913.C b/gcc/testsuite/g++.dg/gomp/pr26913.C new file mode 100644 index 000000000..4f5bb2834 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26913.C @@ -0,0 +1,19 @@ +// PR middle-end/26913 + +struct A +{ + ~A () throw (); +}; + +void foo (A); + +A bar () throw (); + +void baz () +{ +#pragma omp parallel + { + A a; + foo (bar ()); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27310.C b/gcc/testsuite/g++.dg/gomp/pr27310.C new file mode 100644 index 000000000..d921e6af2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27310.C @@ -0,0 +1,22 @@ +// PR middle-end/27310 +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +struct A +{ + ~A (); +}; + +struct B +{ + A a, b; +}; + +void +foo () +{ + A c, d; + +#pragma omp parallel + B e; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27325.C b/gcc/testsuite/g++.dg/gomp/pr27325.C new file mode 100644 index 000000000..05bc481d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27325.C @@ -0,0 +1,25 @@ +// PR middle-end/27325 +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +struct A { A(); ~A(); int i; }; + +int +foo () +{ + A a; +#pragma omp parallel private (a) + for (int i = 0; i < 5; ++i) + a.i++; + return 0; +} + +int +bar () +{ + A a; +#pragma omp for private (a) + for (int i = 0; i < 5; ++i) + a.i++; + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27337-1.C b/gcc/testsuite/g++.dg/gomp/pr27337-1.C new file mode 100644 index 000000000..6c26070ab --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27337-1.C @@ -0,0 +1,22 @@ +// PR middle-end/27337 +// { dg-do compile } + +struct S +{ + S (); + ~S (); + double &operator* () const; +}; + +S +foo () +{ + int i; + S ret; + +#pragma omp parallel for + for (i = 0; i < 2; i++) + *ret += i; + + return ret; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27337-2.C b/gcc/testsuite/g++.dg/gomp/pr27337-2.C new file mode 100644 index 000000000..d1ae4a139 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27337-2.C @@ -0,0 +1,22 @@ +// PR middle-end/27337 +// { dg-do compile } + +struct S +{ + S (); + ~S (); + int i; +}; + +S +foo () +{ + int i; + S ret; + +#pragma omp parallel for firstprivate (ret) lastprivate (ret) + for (i = 0; i < 2; i++) + ret.i += i; + + return ret; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27359.C b/gcc/testsuite/g++.dg/gomp/pr27359.C new file mode 100644 index 000000000..603898c32 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27359.C @@ -0,0 +1,10 @@ +// PR c++/27359 +// { dg-do compile } + +void +foo () +{ +#pragma omp parallel for + for (int i; i < 1; ++i) // { dg-error "expected|was not declared" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27415.C b/gcc/testsuite/g++.dg/gomp/pr27415.C new file mode 100644 index 000000000..81f0ed5c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27415.C @@ -0,0 +1,50 @@ +// PR middle-end/27415 +// { dg-do compile } + +void +test1 (void) +{ + int i = 0; +#pragma omp parallel +#pragma omp for firstprivate (i) // { dg-error "should not be firstprivate" } + for (i = 0; i < 10; i++) + ; +} + +void +test2 (void) +{ + int i = 0; +#pragma omp parallel for firstprivate (i) + for (i = 0; i < 10; i++) // { dg-error "should not be firstprivate" } + ; +} + +void +test3 (void) +{ + int i = 0; +#pragma omp parallel +#pragma omp for reduction (+:i) // { dg-error "should not be reduction" } + for (i = 0; i < 10; i++) + ; +} + +void +test4 (void) +{ + int i = 0; +#pragma omp parallel for reduction (*:i) + for (i = 0; i < 10; i++) // { dg-error "should not be reduction" } + ; +} + +void +test5 (void) +{ + int i = 0; +#pragma omp parallel firstprivate (i) +#pragma omp for + for (i = 0; i < 10; i++) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr27499.C b/gcc/testsuite/g++.dg/gomp/pr27499.C new file mode 100644 index 000000000..4e0d5b1a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr27499.C @@ -0,0 +1,13 @@ +// PR c/27499 +// { dg-do compile } + +extern void bar (unsigned int); + +void +foo (void) +{ + unsigned int i; +#pragma omp for + for (i = 0; i < 64; ++i) + bar (i); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-1.C b/gcc/testsuite/g++.dg/gomp/pr29965-1.C new file mode 100644 index 000000000..efb89ffa6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-1.C @@ -0,0 +1,45 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +static inline void +foo () +{ +#pragma omp parallel + for (;;) + ; +} + +static inline void +bar () +{ +#pragma omp parallel + baz (); +} + +void +foo1 () +{ + foo (); +} + +void +foo2 () +{ + foo (); +} + +void +bar1 () +{ + bar (); +} + +void +bar2 () +{ + bar (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-10.C b/gcc/testsuite/g++.dg/gomp/pr29965-10.C new file mode 100644 index 000000000..2e816da7b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-10.C @@ -0,0 +1,24 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// This is invalid code, but we don't emit diagnostics for it, nevertheless +// we test that we don't ICE on it. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +void +foo1 () +{ + int i; +#pragma omp for schedule (static) + for (i = 0; i < 2834; i++) + throw 0; +} + +void +foo2 () +{ + int i; +#pragma omp parallel for schedule (static) + for (i = 0; i < 2834; i++) + throw 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-2.C b/gcc/testsuite/g++.dg/gomp/pr29965-2.C new file mode 100644 index 000000000..0976ca762 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-2.C @@ -0,0 +1,98 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +void +foo1 () +{ +#pragma omp sections + { + for (;;) + ; + } +} + +void +bar1 () +{ +#pragma omp sections + { +#pragma omp section + baz (); +#pragma omp section + baz (); + } +} + +void +foo2 () +{ +#pragma omp sections + { + ; +#pragma omp section + for (;;) + ; + } +} + +void +bar2 () +{ +#pragma omp sections + { +#pragma omp section + baz (); +#pragma omp section + ; + } +} + +void +foo3 () +{ +#pragma omp parallel sections + { + for (;;) + ; + } +} + +void +bar3 () +{ +#pragma omp parallel sections + { +#pragma omp section + baz (); +#pragma omp section + baz (); + } +} + +void +foo4 () +{ +#pragma omp parallel sections + { + ; +#pragma omp section + for (;;) + ; + } +} + +void +bar4 () +{ +#pragma omp parallel sections + { +#pragma omp section + baz (); +#pragma omp section + ; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-3.C b/gcc/testsuite/g++.dg/gomp/pr29965-3.C new file mode 100644 index 000000000..b98c24e55 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-3.C @@ -0,0 +1,62 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +void +foo1 () +{ +#pragma omp single + for (;;); +} + +void +bar1 () +{ +#pragma omp single + baz (); +} + +void +foo2 () +{ +#pragma omp master + for (;;); +} + +void +bar2 () +{ +#pragma omp master + baz (); +} + +void +foo3 () +{ +#pragma omp ordered + for (;;); +} + +void +bar3 () +{ +#pragma omp ordered + baz (); +} + +void +foo4 () +{ +#pragma omp critical + for (;;); +} + +void +bar4 () +{ +#pragma omp critical + baz (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-4.C b/gcc/testsuite/g++.dg/gomp/pr29965-4.C new file mode 100644 index 000000000..b044fdf70 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-4.C @@ -0,0 +1,44 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +void +foo1 () +{ + int i; +#pragma omp for schedule (dynamic) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar1 () +{ + int i; +#pragma omp for schedule (dynamic) + for (i = 0; i < 2834; i++) + baz (); +} + +void +foo2 () +{ + int i; +#pragma omp parallel for schedule (dynamic) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar2 () +{ + int i; +#pragma omp parallel for schedule (dynamic) + for (i = 0; i < 2834; i++) + baz (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-5.C b/gcc/testsuite/g++.dg/gomp/pr29965-5.C new file mode 100644 index 000000000..cf91dd6dc --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-5.C @@ -0,0 +1,44 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +void +foo1 () +{ + int i; +#pragma omp for schedule (static) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar1 () +{ + int i; +#pragma omp for schedule (static) + for (i = 0; i < 2834; i++) + baz (); +} + +void +foo2 () +{ + int i; +#pragma omp parallel for schedule (static) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar2 () +{ + int i; +#pragma omp parallel for schedule (static) + for (i = 0; i < 2834; i++) + baz (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-6.C b/gcc/testsuite/g++.dg/gomp/pr29965-6.C new file mode 100644 index 000000000..6384d0928 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-6.C @@ -0,0 +1,44 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +extern void baz () __attribute__ ((noreturn)); + +void +foo1 () +{ + int i; +#pragma omp for schedule (static, 16) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar1 () +{ + int i; +#pragma omp for schedule (static, 16) + for (i = 0; i < 2834; i++) + baz (); +} + +void +foo2 () +{ + int i; +#pragma omp parallel for schedule (static, 16) + for (i = 0; i < 2834; i++) + for (;;) + ; +} + +void +bar2 () +{ + int i; +#pragma omp parallel for schedule (static, 16) + for (i = 0; i < 2834; i++) + baz (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-7.C b/gcc/testsuite/g++.dg/gomp/pr29965-7.C new file mode 100644 index 000000000..be7d6ae9d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-7.C @@ -0,0 +1,32 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// This is invalid code, but we don't emit diagnostics for it, nevertheless +// we test that we don't ICE on it. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +void +foo () +{ +#pragma omp parallel + throw 0; +} + +static inline void +bar () +{ +#pragma omp parallel + throw 0; +} + +void +bar1 () +{ + bar (); +} + +void +bar2 () +{ + bar (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-8.C b/gcc/testsuite/g++.dg/gomp/pr29965-8.C new file mode 100644 index 000000000..b2a35287d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-8.C @@ -0,0 +1,94 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// This is invalid code, but we don't emit diagnostics for it, nevertheless +// we test that we don't ICE on it. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +void +foo1 () +{ +#pragma omp sections + { + throw 0; + } +} + +void +bar1 () +{ +#pragma omp sections + { +#pragma omp section + throw 0; +#pragma omp section + throw 0; + } +} + +void +foo2 () +{ +#pragma omp sections + { + ; +#pragma omp section + throw 0; + } +} + +void +bar2 () +{ +#pragma omp sections + { +#pragma omp section + throw 0; +#pragma omp section + ; + } +} + +void +foo3 () +{ +#pragma omp parallel sections + { + throw 0; + } +} + +void +bar3 () +{ +#pragma omp parallel sections + { +#pragma omp section + throw 0; +#pragma omp section + throw 0; + } +} + +void +foo4 () +{ +#pragma omp parallel sections + { + ; +#pragma omp section + throw 0; + } +} + +void +bar4 () +{ +#pragma omp parallel sections + { +#pragma omp section + throw 0; +#pragma omp section + ; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr29965-9.C b/gcc/testsuite/g++.dg/gomp/pr29965-9.C new file mode 100644 index 000000000..b66a24729 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr29965-9.C @@ -0,0 +1,34 @@ +// PR middle-end/29965 +// Test that OpenMP construct bodies which never return don't cause ICEs. +// This is invalid code, but we don't emit diagnostics for it, nevertheless +// we test that we don't ICE on it. +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +void +foo1 () +{ +#pragma omp single + throw 0; +} + +void +foo2 () +{ +#pragma omp master + throw 0; +} + +void +foo3 () +{ +#pragma omp ordered + throw 0; +} + +void +foo4 () +{ +#pragma omp critical + throw 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr30494.C b/gcc/testsuite/g++.dg/gomp/pr30494.C new file mode 100644 index 000000000..3f2d12058 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr30494.C @@ -0,0 +1,30 @@ +// PR middle-end/30494 +// { dg-do compile } + +int +foo (int n) +{ + int i; +#pragma omp for + for (i = 0; i < 6; i++) + { + int v[n], w[n * 3 + i]; + v[0] = 1; + w[0] = 2; + } + return 0; +} + +int +bar (int n) +{ + int i; +#pragma parallel omp for + for (i = 0; i < 6; i++) + { + int v[n], w[n * 3 + i]; + v[0] = 1; + w[0] = 2; + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr30558.C b/gcc/testsuite/g++.dg/gomp/pr30558.C new file mode 100644 index 000000000..e4929220b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr30558.C @@ -0,0 +1,41 @@ +// PR tree-optimization/30558 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> struct F +{ + ~F (); + F (T); + const T &operator[] (unsigned i) const; +}; + +template <typename T> F<T> foo (const F<T> &x) +{ + return F<T> (x[1]); +} + +struct G +{ + G () { bar (2); } + F<int> &operator () (F<int> x); + void bar (int); +}; + +int +main () +{ + try + { + G g; +#pragma omp parallel for + for (int i = 0; i < 10; ++i) + { + F<int> j (i); + F<int> f = g (j); + F<int> h = foo (f); + } + } + catch (int &e) + { + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr30696.C b/gcc/testsuite/g++.dg/gomp/pr30696.C new file mode 100644 index 000000000..8f4f2d968 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr30696.C @@ -0,0 +1,12 @@ +inline void foo() {} + +int main() +{ + foo(); + +#pragma omp parallel for + for ( int i=0; i<1; ++i ) + foo(); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr31598.C b/gcc/testsuite/g++.dg/gomp/pr31598.C new file mode 100644 index 000000000..3ebcead5a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr31598.C @@ -0,0 +1,59 @@ +// PR c++/31598 +// { dg-do compile } +// +// Copyright (C) 2007 Free Software Foundation, Inc. +// Contributed by Theodore.Papadopoulo +// 16 Apr 2007 <Theodore.Papadopoulo@sophia.inria.fr> + +int i; +template <typename> struct A { A() {} }; +template <typename> struct C { C() { i++; } C(const C &) { i += 2; } }; +struct D { D() {} }; + +struct M { typedef double E; }; + +template <typename T> +struct R +{ + R() + { + typedef A<typename T::E> B; + B b; + #pragma omp parallel for firstprivate(b) schedule(guided) + for (int t = 0; t < 10; ++t) + ; + } +}; + +template <typename T> +struct S +{ + S() + { + typedef C<typename T::E> B; + B b; + #pragma omp parallel for firstprivate(b) + for (int t = 0; t < 10; ++t) + ; + } +}; + +struct U +{ + U() + { + D b; + #pragma omp parallel for firstprivate(b) + for (int t = 0; t < 10; ++t) + ; + } +}; + +int +main () +{ + R<M> r; + S<M> s; + U u; + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr31748.C b/gcc/testsuite/g++.dg/gomp/pr31748.C new file mode 100644 index 000000000..516978d28 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr31748.C @@ -0,0 +1,10 @@ +// PR c++/31748 + +struct A; + +void +foo () +{ +#pragma omp parallel private(A) // { dg-error "struct A.*is not a variable" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr31769.C b/gcc/testsuite/g++.dg/gomp/pr31769.C new file mode 100644 index 000000000..54945f94e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr31769.C @@ -0,0 +1,61 @@ +// PR tree-optimization/31769 +// { dg-options "-O2 -fopenmp" } +// { dg-do compile } + +struct B +{ + B () {} + virtual ~B () {} +}; +struct C +{ + C (int x, int y) {} +}; +template<typename T, int U> +struct D +{ + D () {} + ~D () {} +}; +struct E +{ + E () {} + ~E () {} + D<int, 1> e; +}; +struct A +{ + B *b; + A () { b = __null; } + ~A () { if (b != __null) delete b; } +}; +struct F : public A +{ + explicit F (int x) { foo (0); } + F (const F &x) {} + F (F &x, C y) {} + F operator () (C x) const + { + return F (const_cast<F &>(*this), x); + } + template <typename U> F & operator+= (const U &); + void foo (int); + E f; +}; + +int +main () +{ + try + { + F f (10); + F g (10); + C h (0, 9); +#pragma omp parallel for + for (int i = 0; i < 2; ++i) + g += f (h); + } + catch (int &e) + { + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr32177.C b/gcc/testsuite/g++.dg/gomp/pr32177.C new file mode 100644 index 000000000..55c8483be --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr32177.C @@ -0,0 +1,46 @@ +// PR c++/32177 +// { dg-do compile } +// { dg-options "-fopenmp" } +// +// Copyright (C) 2007 Free Software Foundation, Inc. +// Contributed by Theodore.Papadopoulo 1 Jun 2007 <Theodore.Papadopoulo@sophia.inria.fr> + +struct A +{ + A () {} + ~A () {} + int s () const { return 1; } +}; + +void +f1 () +{ + #pragma omp parallel for + for (int i = 1; i <= A ().s (); ++i) + ; +} + +void +f2 () +{ + #pragma omp parallel for + for (int i = A ().s (); i <= 20; ++i) + ; +} + +void +f3 () +{ + #pragma omp parallel for + for (int i = 1; i <= 20; i += A ().s ()) + ; +} + +void +f4 () +{ + int i; + #pragma omp parallel for + for (i = A ().s (); i <= 20; i++) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33333.C b/gcc/testsuite/g++.dg/gomp/pr33333.C new file mode 100644 index 000000000..ea5079b5e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33333.C @@ -0,0 +1,19 @@ +// PR middle-end/33333 +// { dg-do compile } + +struct A +{ + int n; + void foo (); +}; + +void +A::foo () +{ + try + { + #pragma omp parallel for + for (int i = 0; i < n; ++i) + ; + } catch (...) {} +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-1.C b/gcc/testsuite/g++.dg/gomp/pr33372-1.C new file mode 100644 index 000000000..62900bf65 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-1.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> +void f () +{ + extern T n (); +#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" } + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" } + ; +} + +void g () +{ + f<int> (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-2.C b/gcc/testsuite/g++.dg/gomp/pr33372-2.C new file mode 100644 index 000000000..cce7ecc74 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-2.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> +void f () +{ + T n = 6; +#pragma omp parallel num_threads(n) + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) + ; +} + +void g () +{ + f<int> (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-3.C b/gcc/testsuite/g++.dg/gomp/pr33372-3.C new file mode 100644 index 000000000..8220f3c5a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-3.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> +void f () +{ + T n = 6; +#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" } + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" } + ; +} + +void g () +{ + f<double> (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33890.C b/gcc/testsuite/g++.dg/gomp/pr33890.C new file mode 100644 index 000000000..1710b928e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33890.C @@ -0,0 +1,34 @@ +// PR c++/33890 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A +{ + int x; + A () : x (0) {} + int & getX (); +}; + +template <int> void +foo () +{ + A a; + +#pragma omp for + for (int i = a.getX (); i < 10; ++i) + ; +#pragma omp for + for (int i = 0; i < a.getX (); ++i) + ; + a.x = 1; +#pragma omp for + for (int i = 0; i < 10; i += a.getX ()) + ; +} + +void +bar () +{ + foo <0> (); + foo <1> (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr34607.C b/gcc/testsuite/g++.dg/gomp/pr34607.C new file mode 100644 index 000000000..f032aa45d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr34607.C @@ -0,0 +1,18 @@ +// PR c++/34607 +// { dg-do compile } +// { dg-options "-fopenmp" } + +void +foo () +{ +#pragma omp for + for (int i =; i < 2; ++i) // { dg-error "expected primary-expression" } + ; +#pragma omp for + for (T i = 54; i < 56; i++) // { dg-error "was not declared|expected" } + ; + T j; // { dg-error "was not declared|expected" } +#pragma omp for + for (j = 1; j < 3; j++) // { dg-error "was not declared|expected" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr34608.C b/gcc/testsuite/g++.dg/gomp/pr34608.C new file mode 100644 index 000000000..759ab3fca --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr34608.C @@ -0,0 +1,19 @@ +// PR middle-end/34608 +// { dg-do compile } +// { dg-options "-ftest-coverage -fopenmp" } + +struct A +{ + ~A () throw (); +}; + +void foo (A); + +void +bar () +{ +#pragma omp parallel + foo (A ()); +} + +// { dg-final { cleanup-coverage-files } } diff --git a/gcc/testsuite/g++.dg/gomp/pr34694.C b/gcc/testsuite/g++.dg/gomp/pr34694.C new file mode 100644 index 000000000..c225e1545 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr34694.C @@ -0,0 +1,15 @@ +// PR middle-end/34694 +// { dg-do compile } +// { dg-options "-O -fopenmp -Wall" } + +int i; + +void +foo () +{ +#pragma omp parallel + { + int j; // { dg-message "note: 'j' was declared here" } + i = j; // { dg-warning "is used uninitialized" } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr34964.C b/gcc/testsuite/g++.dg/gomp/pr34964.C new file mode 100644 index 000000000..f5995a6da --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr34964.C @@ -0,0 +1,6 @@ +// PR c++/34964 +// { dg-do compile } +// { dg-options "-fopenmp" } + +char x[] = 0; // { dg-error "initializer fails to determine size" } +#pragma omp threadprivate (x) diff --git a/gcc/testsuite/g++.dg/gomp/pr35028.C b/gcc/testsuite/g++.dg/gomp/pr35028.C new file mode 100644 index 000000000..ef7ba07de --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35028.C @@ -0,0 +1,19 @@ +// PR c++/35028 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A +{ + A (); + A (const A &, ...); + ~A (); + A operator++ (int); +}; + +void +foo () +{ + A a; + #pragma omp parallel firstprivate (a) + a++; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35078.C b/gcc/testsuite/g++.dg/gomp/pr35078.C new file mode 100644 index 000000000..1f0d9ec7f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35078.C @@ -0,0 +1,20 @@ +// PR c++/35078 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template<int> void +foo () +{ +#pragma omp parallel for + for (int& i = 0; i < 10; ++i) // { dg-error "invalid type for iteration variable" } + ; +} + +void +bar () +{ + int j = 0; +#pragma omp parallel for + for (int& i = j; i < 10; ++i) // { dg-error "invalid type for iteration variable" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35099.C b/gcc/testsuite/g++.dg/gomp/pr35099.C new file mode 100644 index 000000000..6c793a3f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35099.C @@ -0,0 +1,39 @@ +// PR middle-end/35099 +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +struct A +{ + ~A () throw (); + void foo (); +}; + +struct B +{ + B () { A ().foo (); } +}; + +void +bar () +{ +#pragma omp parallel + { + #pragma omp single + B (); + #pragma omp for + for (int i = 0; i < 2; ++i) + B (); + } +} + +void +baz () +{ +#pragma omp parallel + { + #pragma omp single + B (); + #pragma omp single + B (); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35158.C b/gcc/testsuite/g++.dg/gomp/pr35158.C new file mode 100644 index 000000000..9577cd236 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35158.C @@ -0,0 +1,14 @@ +// PR c++/35158 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int main(int argc, char *argv[]) +{ +#pragma omp parallel for + for (int i(0) ; // { dg-error "parenthesized initialization is not allowed in OpenMP 'for' loop" } + i < 10 ; + i++) + ; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35244.C b/gcc/testsuite/g++.dg/gomp/pr35244.C new file mode 100644 index 000000000..022f9d0a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35244.C @@ -0,0 +1,30 @@ +// PR c++/35244 +// { dg-do compile } +// { dg-require-effective-target tls } +// { dg-options "-fopenmp" } + +int v1; +namespace N1 +{ + int v2; +} +namespace N2 +{ + int v3; +} +using N1::v2; +using namespace N2; +struct A; +typedef int i; +#pragma omp threadprivate (i) // { dg-error "is not file, namespace or block scope variable" } +#pragma omp threadprivate (A) // { dg-error "is not file, namespace or block scope variable" } +#pragma omp threadprivate (v1, v2, v3) + +void foo () +{ + static int v4; + { + static int v5; +#pragma omp threadprivate (v4, v5) + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35328.C b/gcc/testsuite/g++.dg/gomp/pr35328.C new file mode 100644 index 000000000..718283b59 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35328.C @@ -0,0 +1,31 @@ +// PR c++/35328 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A +{ + ~A ()(); // { dg-error "declared as function returning a function" } +}; +struct B +{ + B ()(); // { dg-error "declared as function returning a function" } +}; +struct C +{ + C (); + C (const C &)(); // { dg-error "declared as function returning a function" } +}; + +void +foo () +{ + A a; + B b; + C c; + #pragma omp parallel firstprivate (a) + ; + #pragma omp parallel private (b) + ; + #pragma omp parallel firstprivate (c) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35337.C b/gcc/testsuite/g++.dg/gomp/pr35337.C new file mode 100644 index 000000000..2e9ca6b20 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35337.C @@ -0,0 +1,20 @@ +// PR c++/35337 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A { }; + +void +foo () +{ +#pragma omp parallel firstprivate(A) // { dg-error "struct A\[^\n\]*is not a variable" } + ; +} + +void +bar () +{ +#pragma omp for lastprivate(A) // { dg-error "struct A\[^\n\]*is not a variable" } + for (int i = 0; i < 10; i++) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35364.C b/gcc/testsuite/g++.dg/gomp/pr35364.C new file mode 100644 index 000000000..da60d5deb --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35364.C @@ -0,0 +1,50 @@ +// PR target/35364 +// { dg-do compile } +// { dg-options "-O2 -fopenmp" } + +template <typename T> +struct E +{ + E (); + ~E (); +}; + +template <typename T, typename U> +struct C +{ + C (const U &y) : u (y) {} + ~C () {} + const U &u; +}; + +template <typename T, typename U = E<T> > +struct B : public C<T, U> +{ + B (int x, const T &z = T (), const U &y = U ()) : C<T, U> (y) {} + ~B () {} +}; + +void +foo () +{ +#pragma omp parallel + { + B<double> x (1); + } +#pragma omp for + for (int i = 0; i < 10; i++) + { + B<int> x (i); + } +#pragma omp sections + { +#pragma omp section + { + B<int> x (6); + } + } +#pragma omp single + { + B<int> x (16); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr35751.C b/gcc/testsuite/g++.dg/gomp/pr35751.C new file mode 100644 index 000000000..0b6cded59 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr35751.C @@ -0,0 +1,34 @@ +// PR c/35751 +// { dg-do compile } +// { dg-options "-fopenmp" } + +void +foo (int i) +{ + extern int a[i]; // { dg-error "storage size of" } + static int b[i]; // { dg-error "storage size of" } + +#pragma omp parallel + { + a[0] = 0; + b[0] = 0; + } + +#pragma omp parallel shared (a, b) + { + a[0] = 0; + b[0] = 0; + } + +#pragma omp parallel private (a, b) + { + a[0] = 0; + b[0] = 0; + } + +#pragma omp parallel firstprivate (a, b) + { + a[0] = 0; + b[0] = 0; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr36237.C b/gcc/testsuite/g++.dg/gomp/pr36237.C new file mode 100644 index 000000000..29c7adc8a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr36237.C @@ -0,0 +1,25 @@ +// PR c++/36237 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A +{ + ~A (); +}; + +struct B +{ + B (const A &x = A ()) : a (x) { } + A a; +}; + +B var; + +void bar (); + +void +foo () +{ + #pragma omp parallel private (var) + bar (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr36790.C b/gcc/testsuite/g++.dg/gomp/pr36790.C new file mode 100644 index 000000000..07e8b1052 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr36790.C @@ -0,0 +1,23 @@ +// PR middle-end/36790 +// { dg-do compile } +// { dg-options "-fopenmp -O2" } + +void +foo (bool b) +{ +} + +void +bar (bool b) +{ + foo (b); + #pragma omp task default (shared) + b = false; +} + +int +main () +{ + bar (false); + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr37189.C b/gcc/testsuite/g++.dg/gomp/pr37189.C new file mode 100644 index 000000000..31d95f2d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr37189.C @@ -0,0 +1,27 @@ +// PR c++/37189 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct S +{ + S () {} + S (S const &) {} +}; + +struct T +{ + S s; +}; + +void +bar (T &) +{ +} + +int +foo () +{ + T t; + #pragma omp task + bar (t); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr37346.C b/gcc/testsuite/g++.dg/gomp/pr37346.C new file mode 100644 index 000000000..b6619edc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr37346.C @@ -0,0 +1,15 @@ +// PR c++/37346 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A +{ + A (); + int i; +}; + +A::A () +{ +#pragma omp critical + i++; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr37533.C b/gcc/testsuite/g++.dg/gomp/pr37533.C new file mode 100644 index 000000000..7bf61945b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr37533.C @@ -0,0 +1,50 @@ +// PR c++/37533 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template<int> +void +f1 () +{ +#pragma omp parallel for + for (int i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<int> +void +f2 () +{ + int i; +#pragma omp parallel for + for (i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<typename T> +void +f3 () +{ +#pragma omp parallel for + for (T i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +template<typename T> +void +f4 () +{ + T i; +#pragma omp parallel for + for (i = ""; i < 4; ++i) // { dg-error "invalid conversion from" } + ; +} + +void +bar () +{ + f1<0> (); // { dg-message "instantiated from here" } + f2<1> (); // { dg-message "instantiated from here" } + f3<int> (); // { dg-message "instantiated from here" } + f4<int> (); // { dg-message "instantiated from here" } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr38633.C b/gcc/testsuite/g++.dg/gomp/pr38633.C new file mode 100644 index 000000000..99b879573 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr38633.C @@ -0,0 +1,14 @@ +// PR middle-end/38633 +// { dg-do compile } +// { dg-options "-fopenmp" } + +void +foo () +{ +#pragma omp parallel + { + struct A { int i; } j; + j.i = 6; + j.i++; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr38639.C b/gcc/testsuite/g++.dg/gomp/pr38639.C new file mode 100644 index 000000000..1da3cecdf --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr38639.C @@ -0,0 +1,17 @@ +// PR c++/38639 +// { dg-do compile } +// { dg-options "-fopenmp -std=c++0x" } + +template<int> void +foo () +{ +#pragma omp parallel for + for (auto i = i = 0; i<4; ++i) // { dg-error "incomplete|unable|invalid" } + ; +} + +void +bar () +{ + foo<0> (); // { dg-message "instantiated from here" } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr39495-1.C b/gcc/testsuite/g++.dg/gomp/pr39495-1.C new file mode 100644 index 000000000..8563e684f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr39495-1.C @@ -0,0 +1,95 @@ +// PR c/39495 +// { dg-do compile } +// { dg-options "-fopenmp" } + +#define INT_MIN (-__INT_MAX__ - 1) +#define INT_MAX __INT_MAX__ +#define UINT_MAX (2U * __INT_MAX__ + 1) + +int +foo (void) +{ + int i; + unsigned int u; + +#pragma omp for + for (i = INT_MIN + 6; i > INT_MIN + 1; i--) + ; +#pragma omp for + for (i = INT_MIN + 6; i >= INT_MIN + 1; i--) + ; +#pragma omp for + for (i = INT_MIN + 6; i > INT_MIN; i--) + ; +#pragma omp for + for (i = INT_MAX - 6; i < INT_MAX - 1; i++) + ; +#pragma omp for + for (i = INT_MAX - 6; i <= INT_MAX - 1; i++) + ; +#pragma omp for + for (i = INT_MAX - 6; i < INT_MAX; i++) + ; +#pragma omp for + for (u = 6; u > 1; u--) + ; +#pragma omp for + for (u = 6; u >= 1; u--) + ; +#pragma omp for + for (u = 6; u > 0; u--) + ; +#pragma omp for + for (u = UINT_MAX - 6; u < UINT_MAX - 1; u++) + ; +#pragma omp for + for (u = UINT_MAX - 6; u <= UINT_MAX - 1; u++) + ; +#pragma omp for + for (u = UINT_MAX - 6; u < UINT_MAX; u++) + ; +} + +int +bar (void) +{ + int i; + unsigned int u; + +#pragma omp for + for (i = INT_MIN + 6; i > INT_MIN + 1; i -= 2) + ; +#pragma omp for + for (i = INT_MIN + 6; i >= INT_MIN + 1; i -= 2) + ; +#pragma omp for + for (i = INT_MIN + 6; i > INT_MIN; i -= 2) + ; +#pragma omp for + for (i = INT_MAX - 6; i < INT_MAX - 1; i += 2) + ; +#pragma omp for + for (i = INT_MAX - 6; i <= INT_MAX - 1; i += 2) + ; +#pragma omp for + for (i = INT_MAX - 6; i < INT_MAX; i += 2) + ; +#pragma omp for + for (u = 6; u > 1; u -= 2) + ; +#pragma omp for + for (u = 6; u >= 1; u -= 2) + ; +#pragma omp for + for (u = 6; u > 0; u -= 2) + ; +#pragma omp for + for (u = UINT_MAX - 6; u < UINT_MAX - 1; u += 2) + ; +#pragma omp for + for (u = UINT_MAX - 6; u <= UINT_MAX - 1; u += 2) + ; +#pragma omp for + for (u = UINT_MAX - 6; u < UINT_MAX; u += 2) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr39495-2.C b/gcc/testsuite/g++.dg/gomp/pr39495-2.C new file mode 100644 index 000000000..c0b4d5dbd --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr39495-2.C @@ -0,0 +1,39 @@ +// PR c/39495 +// { dg-do compile } +// { dg-options "-fopenmp" } + +#define INT_MIN (-__INT_MAX__ - 1) +#define INT_MAX __INT_MAX__ +#define UINT_MAX (2U * __INT_MAX__ + 1) + +int +foo (void) +{ + int i; + unsigned int u; + +#pragma omp for + for (i = INT_MIN + 6; i != INT_MIN; i--) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (i = INT_MIN + 6; i == INT_MIN; i--) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (i = INT_MAX - 6; i != INT_MAX; i++) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (i = INT_MAX - 6; i == INT_MAX; i++) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (u = 6; u != 0; u--) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (u = 6; u == 0; u--) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (u = UINT_MAX - 6; u != UINT_MAX; u++) // { dg-error "invalid controlling predicate" } + ; +#pragma omp for + for (u = UINT_MAX - 6; u == UINT_MAX; u++) // { dg-error "invalid controlling predicate" } + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr41429.C b/gcc/testsuite/g++.dg/gomp/pr41429.C new file mode 100644 index 000000000..7de41b846 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr41429.C @@ -0,0 +1,5 @@ +// PR middle-end/41429 +// { dg-do compile { target fpic } } +// { dg-options "-fopenmp -O2 -fpic" } + +#include "pr37189.C" diff --git a/gcc/testsuite/g++.dg/gomp/pr41967.C b/gcc/testsuite/g++.dg/gomp/pr41967.C new file mode 100644 index 000000000..0eb489e8b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr41967.C @@ -0,0 +1,17 @@ +// PR c++/41967 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int +foo () +{ + int sum = 0; +#pragma omp for collapse(2) + for (int i = 0; i < 5; ++i) + { + for (int j = 0; j < 5; ++j) + ++sum; + ++sum; // { dg-error "collapsed loops not perfectly nested" } + } + return sum; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr42234.C b/gcc/testsuite/g++.dg/gomp/pr42234.C new file mode 100644 index 000000000..9245b6c68 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr42234.C @@ -0,0 +1,19 @@ +// PR c++/42234 +// { dg-do compile } +// { dg-options "-fopenmp" } + +extern int foo (void); + +void +bar (int x) +{ + #pragma omp critical + { + int j; + for (j = 0; j < foo (); j++) + ; + if (0) + if (x >= 4) + ; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr47963.C b/gcc/testsuite/g++.dg/gomp/pr47963.C new file mode 100644 index 000000000..7c94e6422 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr47963.C @@ -0,0 +1,11 @@ +// PR c/47963 +// { dg-do compile } +// { dg-options "-fopenmp" } + +void +foo (float n) +{ + int A[n][n]; // { dg-error "has non-integral type" } +#pragma omp parallel private(A) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr48632.C b/gcc/testsuite/g++.dg/gomp/pr48632.C new file mode 100644 index 000000000..afa8b1893 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr48632.C @@ -0,0 +1,22 @@ +// PR c++/48632 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template<typename T> +void +foo (T *x, T *y, unsigned z) +{ +#pragma omp parallel for + for (T *p = x; p < y; p += z) + ; +#pragma omp parallel for + for (T *p = y; p > x; p -= z) + ; +} + +int +main () +{ + char buf[10]; + foo (&buf[0], &buf[9], 1); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr48716.C b/gcc/testsuite/g++.dg/gomp/pr48716.C new file mode 100644 index 000000000..2dccad2d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr48716.C @@ -0,0 +1,24 @@ +// PR c/48716 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int +main (void) +{ + #pragma omp parallel default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } + #pragma omp task default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr49223-1.C b/gcc/testsuite/g++.dg/gomp/pr49223-1.C new file mode 100644 index 000000000..307210fe1 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr49223-1.C @@ -0,0 +1,28 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <int N> +struct V +{ + V () {} + ~V () {} +}; + +template <int N> +struct S +{ + void foo () + { + V <0> v; + #pragma omp parallel private (v) + ; + } +}; + +void +bar (void) +{ + S <0> s; + s.foo (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr49223-2.C b/gcc/testsuite/g++.dg/gomp/pr49223-2.C new file mode 100644 index 000000000..95397733e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr49223-2.C @@ -0,0 +1,16 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-require-effective-target tls } +// { dg-options "-fopenmp" } + +struct S; // { dg-error "forward declaration" } +extern __thread struct S s; // { dg-error "has incomplete type" } +struct T; +extern __thread struct T t; + +void +foo () +{ + #pragma omp parallel copyin (s) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr51360-2.C b/gcc/testsuite/g++.dg/gomp/pr51360-2.C new file mode 100644 index 000000000..cc03849a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr51360-2.C @@ -0,0 +1,21 @@ +/* PR c/51360 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused -W -fopenmp" } */ + +void +foo (int a, int b, int c) +{ + int m, n, o, i; + m = 6; + n = 1; + o = 5; + a = 6; + b = 1; + c = 5; + #pragma omp parallel for num_threads (m) if (n) schedule (static, o) + for (i = 0; i < 10; i++) + ; + #pragma omp parallel for num_threads (a) if (b) schedule (static, c) + for (i = 0; i < 10; i++) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr51360.C b/gcc/testsuite/g++.dg/gomp/pr51360.C new file mode 100644 index 000000000..06c64873c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr51360.C @@ -0,0 +1,28 @@ +// PR c/51360 +// { dg-do compile } +// { dg-options "-Wunused -W -fopenmp" } + +template <typename T> +void +foo (T a, T b, T c) +{ + T m, n, o, i; + m = 6; + n = 1; + o = 5; + a = 6; + b = 1; + c = 5; + #pragma omp parallel for num_threads (m) if (n) schedule (static, o) + for (i = 0; i < 10; i++) + ; + #pragma omp parallel for num_threads (a) if (b) schedule (static, c) + for (i = 0; i < 10; i++) + ; +} + +void +bar () +{ + foo (0, 0, 0); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr51669.C b/gcc/testsuite/g++.dg/gomp/pr51669.C new file mode 100644 index 000000000..ab99d93e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr51669.C @@ -0,0 +1,32 @@ +// PR c++/51669 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> const T & min (const T &, const T &); + +void +f1 () +{ +#pragma omp parallel num_threads (min (4, 5)) + ; +} + +struct A { A (); ~A (); }; +int foo (const A &); + +void +f2 () +{ + int i; +#pragma omp parallel if (foo (A ())) num_threads (foo (A ())) + ; +#pragma omp task if (foo (A ())) + ; +#pragma omp for schedule (static, foo (A ())) + for (i = 0; i < 10; i++) + ; +#pragma omp parallel for schedule (static, foo (A ())) \ + if (foo (A ())) num_threads (foo (A ())) + for (i = 0; i < 10; i++) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/predetermined-1.C b/gcc/testsuite/g++.dg/gomp/predetermined-1.C new file mode 100644 index 000000000..dd09855de --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/predetermined-1.C @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A { int i; A (); ~A (); }; +struct B { int i; }; +struct C { int i; mutable int j; C (); ~C (); }; + +template <typename T> void bar (const T *); + +const A a; +const C c; + +const A foo (const A d, const C e) +{ + const A f; + const B b = { 4 }; + A g; + #pragma omp parallel default (none) + bar (&a); + #pragma omp parallel default (none) + bar (&b); + #pragma omp parallel default (none) // { dg-error "enclosing parallel" } + bar (&c); // { dg-error "not specified" } + #pragma omp parallel default (none) + bar (&d); + #pragma omp parallel default (none) // { dg-error "enclosing parallel" } + bar (&e); // { dg-error "not specified" } + #pragma omp parallel default (none) + bar (&f); + #pragma omp parallel default (none) // { dg-error "enclosing parallel" } + bar (&g); // { dg-error "not specified" } + return f; +} diff --git a/gcc/testsuite/g++.dg/gomp/sections-1.C b/gcc/testsuite/g++.dg/gomp/sections-1.C new file mode 100644 index 000000000..43704908e --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/sections-1.C @@ -0,0 +1,39 @@ +/* { dg-do compile } */ + +extern void bar(int); + +void f1(void) +{ + #pragma omp sections nowait + { + bar (1); + #pragma omp section + bar (2); + #pragma omp section + bar (3); + #pragma omp section + bar (4); + #pragma omp section + bar (5); + } +} + +void f2(void) +{ + #pragma omp sections + { + #pragma omp section + { + bar (1); + bar (1); + } + #pragma omp section + bar (2); + #pragma omp section + bar (3); + #pragma omp section + bar (4); + #pragma omp section + bar (5); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/sections-2.C b/gcc/testsuite/g++.dg/gomp/sections-2.C new file mode 100644 index 000000000..aabdfaf80 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/sections-2.C @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +extern void bar(int); +void foo(void) +{ + #pragma omp sections + bar (0); // { dg-error "expected" } + + #pragma omp sections + { + } // { dg-error "expected" } + + #pragma omp sections + { + bar (1); + } + + #pragma omp sections + { + #pragma omp section + bar(2); + bar(3); // { dg-error "expected" } + bar(4); + #pragma omp section + bar(5); + bar(6); // { dg-error "expected" } + bar(7); + } +} diff --git a/gcc/testsuite/g++.dg/gomp/sections-3.C b/gcc/testsuite/g++.dg/gomp/sections-3.C new file mode 100644 index 000000000..d8fb2a09d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/sections-3.C @@ -0,0 +1,15 @@ + +// { dg-do compile } + +extern void bar (void); + +int main (void) +{ + #pragma omp parallel sections nowait /* { dg-error "'nowait'" } */ + { + #pragma omp section + { bar(); } + #pragma omp section + { bar(); } + } +} diff --git a/gcc/testsuite/g++.dg/gomp/sections-4.C b/gcc/testsuite/g++.dg/gomp/sections-4.C new file mode 100644 index 000000000..62a2ecddf --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/sections-4.C @@ -0,0 +1,13 @@ +/* PR c++/24613 */ +/* { dg-do compile } */ + +#pragma omp section /* { dg-error "may only be used in" } */ + +int i; + +void +foo (void) +{ + #pragma omp section /* { dg-error "may only be used in" } */ + i++; +} diff --git a/gcc/testsuite/g++.dg/gomp/sharing-1.C b/gcc/testsuite/g++.dg/gomp/sharing-1.C new file mode 100644 index 000000000..83b818098 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/sharing-1.C @@ -0,0 +1,77 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ + +int thrglobalvar; +#pragma omp threadprivate (thrglobalvar) +int globalvar; +const struct S +{ + int x; +} constvar = { 8 }; +struct T +{ + static T t; + int i; +}; +T T::t = { 6 }; +/* const qualified type, but mutable member -> not predetermined. */ +const struct U +{ + int x; + mutable int y; +} constmutvar = { 6, 4 }; + +int +foo (int x) +{ + return x; +} + +int +bar (int *x) +{ + return *x; +} + +int +baz (U u) +{ + return u.x; +} + +int +main (void) +{ + static int thrlocvar; +#pragma omp threadprivate (thrlocvar) + static int locvar; + static int *p; + int i, j, s, l; + + p = new int; + *p = 7; + s = 6; + l = 0; +#pragma omp parallel for /* { dg-error "enclosing parallel" } */ \ + default (none) private (p) shared (s) + for (i = 0; i < 64; i++) + { + int k = foo (0); /* Predetermined - private (automatic var declared */ + k++; /* in scope of construct). */ + thrglobalvar++; /* Predetermined - threadprivate. */ + thrlocvar++; /* Predetermined - threadprivate. */ + foo (i); /* Predetermined - private (omp for loop variable). */ + foo (constvar.x); /* Predetermined - shared (const qualified type). */ + foo (T::t.i); /* Predetermined - shared (static data member). */ + foo (*p); /* *p predetermined - shared (heap allocated */ + (*p)++; /* storage). */ + bar (p); /* Explicitly determined - private. */ + foo (s); /* Explicitly determined - shared. */ + globalvar++; /* { dg-error "not specified in" } */ + locvar++; /* { dg-error "not specified in" } */ + l++; /* { dg-error "not specified in" } */ + for (j = 0; j < 2; j++); /* { dg-error "not specified in" } */ + baz (constmutvar);/* { dg-error "not specified in" } */ + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/task-1.C b/gcc/testsuite/g++.dg/gomp/task-1.C new file mode 100644 index 000000000..0000e6f1f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/task-1.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A { A (); ~A (); int i; }; + +template <typename T> void bar (T &); + +const A a; + +void foo (A &p) +{ + const A &q = a; +#pragma omp task // { dg-error "has reference type" } + bar (p); +#pragma omp task // { dg-error "has reference type" } + bar (q); +} diff --git a/gcc/testsuite/g++.dg/gomp/tls-1.C b/gcc/testsuite/g++.dg/gomp/tls-1.C new file mode 100644 index 000000000..bfe62cb00 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tls-1.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-require-effective-target tls } + +int tp1; +static int tp2; +extern int tp3; + +int tp4 = 1; +static int tp5 = 1; + +#pragma omp threadprivate (tp1, tp2, tp3, tp4, tp5) + +#pragma omp threadprivate (undef) // { dg-error "declared" } + +int tp6; +int foo(void) { return tp6; } + +#pragma omp threadprivate (tp6) // { dg-error "after first use" } diff --git a/gcc/testsuite/g++.dg/gomp/tls-2.C b/gcc/testsuite/g++.dg/gomp/tls-2.C new file mode 100644 index 000000000..80275f908 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tls-2.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ + +extern char buf[]; +#pragma omp threadprivate (buf) /* { dg-error "has incomplete type" } */ + +void +foo (void) +{ + int i; +#pragma omp threadprivate (i) /* { dg-error "automatic variable" } */ + i = 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/tls-3.C b/gcc/testsuite/g++.dg/gomp/tls-3.C new file mode 100644 index 000000000..c710b6d18 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tls-3.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-require-effective-target tls } + +#define thr threadprivate + +int i; +#pragma omp thr (i) +namespace N +{ + int j; +#pragma omp thr (j) +}; +struct S +{ + static int s; +#pragma omp thr (s) +}; + +int S::s = 5; + +int +foo () +{ + static int k; +#pragma omp thr (k) + return k++ + S::s; +} diff --git a/gcc/testsuite/g++.dg/gomp/tls-4.C b/gcc/testsuite/g++.dg/gomp/tls-4.C new file mode 100644 index 000000000..f6c039e3d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tls-4.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-require-effective-target tls } + +#define thr threadprivate + +struct S +{ + static int s; +}; +struct T : public S +{ + static int t; +#pragma omp thr (s) // { dg-error "directive not in" } +}; + +#pragma omp thr (T::t) // { dg-error "directive not in" } diff --git a/gcc/testsuite/g++.dg/gomp/tpl-atomic-1.C b/gcc/testsuite/g++.dg/gomp/tpl-atomic-1.C new file mode 100644 index 000000000..ff1e3632d --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-atomic-1.C @@ -0,0 +1,26 @@ +// { dg-do compile } + +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; +} + +void test () +{ + int i; + long l; + + foo<char>(); + foo<short>(); + bar(&i, 4); + bar(&l, 8L); +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-atomic-2.C b/gcc/testsuite/g++.dg/gomp/tpl-atomic-2.C new file mode 100644 index 000000000..c27f20193 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-atomic-2.C @@ -0,0 +1,40 @@ +// { dg-do compile } + +struct S { int x; } s; + +// Make sure we detect errors on non-type-dependent things +// even when the templates are never instantiated. +template<typename T> void f1() +{ + #pragma omp atomic + s += 1; // { dg-error "invalid" } +} + +template<typename T> void f2(float *f) +{ + #pragma omp atomic + *f |= 1; // { dg-error "invalid|evaluation" } +} + +// Here the rhs is dependent, but not type dependent. +template<typename T> void f3(float *f) +{ + #pragma omp atomic + *f |= sizeof (T); // { dg-error "invalid|evaluation" } +} + +// And the converse, no error here because we're never fed a T. +template<typename T> void f4(T *t) +{ + #pragma omp atomic + *t += 1; +} + +// Here we'll let it go, because the rhs is type dependent and +// we can't properly instantiate the statement, and we do most +// of the semantic analysis concurrent with that. +template<typename T> void f5(float *f) +{ + #pragma omp atomic + *f |= (T)sizeof(T); // { dg-error "invalid|evaluation" "" { xfail *-*-* } } +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-barrier-1.C b/gcc/testsuite/g++.dg/gomp/tpl-barrier-1.C new file mode 100644 index 000000000..60567d910 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-barrier-1.C @@ -0,0 +1,25 @@ +// PR c++/24735 +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-gimple" } + +template <int> void f1 () +{ + #pragma omp barrier +} + +template <int> void f2 (bool p) +{ + if (p) + { + #pragma omp barrier + } +} + +void f3 () +{ + f1<0> (); + f2<0> (true); +} + +// { dg-final { scan-tree-dump-times "GOMP_barrier" 2 "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } diff --git a/gcc/testsuite/g++.dg/gomp/tpl-for-1.C b/gcc/testsuite/g++.dg/gomp/tpl-for-1.C new file mode 100644 index 000000000..e036e6447 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-for-1.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +void foo(int); +void foo(long); + +template<typename T> void bar() +{ + #pragma omp for + for (T i = 0; i < 10; ++i) + foo(i); +} + +void test() +{ + bar<int>(); + bar<long>(); +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-for-2.C b/gcc/testsuite/g++.dg/gomp/tpl-for-2.C new file mode 100644 index 000000000..a3bb6ccd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-for-2.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +void foo(int); + +template<int A, int B, int C> void bar() +{ + #pragma omp for + for (int i = A; i < B; i += C) + foo(i); +} + +void test() +{ + bar<0, 10, 2>(); +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-for-3.C b/gcc/testsuite/g++.dg/gomp/tpl-for-3.C new file mode 100644 index 000000000..0cafd9628 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-for-3.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +void foo(int); + +template<typename T> void bar() +{ + #pragma omp parallel for + for (typename T::T i = 0; i < T::N; ++i) + foo(i); +} + +struct A +{ + typedef int T; + static T N; +}; + +struct B +{ + typedef long T; + static T N; +}; + +void test() +{ + bar<A>(); + bar<B>(); +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-master-1.C b/gcc/testsuite/g++.dg/gomp/tpl-master-1.C new file mode 100644 index 000000000..cf22e1c3f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-master-1.C @@ -0,0 +1,30 @@ +// PR c++/24734 +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-gimple" } + +int i; + +template <int> void f1 () +{ + #pragma omp ordered + i++; +} + +template <int> void f2 (bool p) +{ + if (p) + { + #pragma omp master + i++; + } +} + +void f3 () +{ + f1<0> (); + f2<0> (true); +} + +// { dg-final { scan-tree-dump-times "#pragma omp ordered" 1 "gimple" } } +// { dg-final { scan-tree-dump-times "#pragma omp master" 1 "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } diff --git a/gcc/testsuite/g++.dg/gomp/tpl-parallel-1.C b/gcc/testsuite/g++.dg/gomp/tpl-parallel-1.C new file mode 100644 index 000000000..886d07e21 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-parallel-1.C @@ -0,0 +1,24 @@ +// { dg-do compile } + +int check; + +template<typename T> void foo() +{ + check |= sizeof(T); +} + +template<typename T> +void bar(void) +{ + #pragma omp parallel if (0) + foo<T>(); +} + +int main() +{ + bar<char>(); + bar<short>(); + if (check != (sizeof(char) | sizeof(short))) + __builtin_trap (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/gomp/tpl-parallel-2.C b/gcc/testsuite/g++.dg/gomp/tpl-parallel-2.C new file mode 100644 index 000000000..2dceb0932 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/tpl-parallel-2.C @@ -0,0 +1,20 @@ +// { dg-do compile } + +template<typename T> +struct S +{ + T n; + void test(); + void work(); +}; + +template<typename T> +void S<T>::test() +{ + #pragma omp parallel num_threads(n) // { dg-error "must be integral" } + work(); +} + +template struct S<int>; +template struct S<long>; +template struct S<float>; // { dg-message "instantiated from here" } |