diff options
author | David Malcolm <dmalcolm@redhat.com> | 2023-03-03 18:18:51 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2023-03-03 18:18:51 -0500 |
commit | df0184906a7b86a497c038766366904a20b5601e (patch) | |
tree | 41532a81b9c7546ff74a219dc4497a46034f6e0d | |
parent | 56572a08ec4a0fc1a7802d3737cd7f7cc9089c4b (diff) | |
download | gcc-df0184906a7b86a497c038766366904a20b5601e.zip gcc-df0184906a7b86a497c038766366904a20b5601e.tar.gz gcc-df0184906a7b86a497c038766366904a20b5601e.tar.bz2 |
analyzer: start adding test coverage for OpenMP [PR109016]
gcc/testsuite/ChangeLog:
PR analyzer/109016
* gcc.dg/analyzer/omp-parallel-for-1.c: New test.
* gcc.dg/analyzer/omp-parallel-for-get-min.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-1.c | 21 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-get-min.c | 24 |
2 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-1.c b/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-1.c new file mode 100644 index 0000000..dae940d --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-1.c @@ -0,0 +1,21 @@ +/* { dg-additional-options "-fopenmp -Wall" } */ + +typedef struct _Image +{ + int columns, rows; +} Image; + +extern int get_num_threads(void); + +void +test (Image* image) +{ + int y; + +#pragma omp parallel for schedule(static) \ + num_threads(get_num_threads ()) + + for (y = 0; y < image->rows; y++) { + /* [...snip...] */ + } +} diff --git a/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-get-min.c b/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-get-min.c new file mode 100644 index 0000000..a7e64e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/omp-parallel-for-get-min.c @@ -0,0 +1,24 @@ +/* Reduced from ImageMagick-7.1.0-57's MagickCore/attribute.c: GetEdgeBackgroundColor */ + +/* { dg-additional-options "-fopenmp -Wall" } */ + +extern double get_census (void); + +double +test() +{ + double census[4], edge_census; + int i; + +#pragma omp parallel for schedule(static) + + for (i = 0; i < 4; i++) { + census[i] = get_census (); + } + edge_census = (-1.0); + for (i = 0; i < 4; i++) + if (census[i] > edge_census) { /* { dg-bogus "use of uninitialized value" } */ + edge_census = census[i]; + } + return edge_census; +} |