[committed] Diagnose invalid #pragma omp simd even for -fopenmp-simd (PR middle-end/81052)
Jakub Jelinek
jakub@redhat.com
Thu Aug 3 08:37:00 GMT 2017
Hi!
The (mini)pass to diagnose invalid OpenMP/OpenACC/Cilk+ constructs wasn't
mistakenly run for -fopenmp-simd, so non-conforming simd constructs weren't
diagnosed, but could easily ICE later on, because we assume the body of the
loop is a structured block (single entry, single exit, no branches into it
or out of it, no exceptions thrown out of it etc.).
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk so
far, queued for backporting.
2017-08-03 Jakub Jelinek <jakub@redhat.com>
PR middle-end/81052
* omp-low.c (diagnose_sb_0): Handle flag_openmp_simd like flag_openmp.
(pass_diagnose_omp_blocks::gate): Enable also for flag_openmp_simd.
* c-c++-common/pr81052.c: New test.
--- gcc/omp-low.c.jj 2017-07-06 20:31:32.000000000 +0200
+++ gcc/omp-low.c 2017-08-02 12:52:47.608735787 +0200
@@ -9083,7 +9083,7 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi
}
if (kind == NULL)
{
- gcc_checking_assert (flag_openmp);
+ gcc_checking_assert (flag_openmp || flag_openmp_simd);
kind = "OpenMP";
}
@@ -9343,7 +9343,7 @@ public:
/* opt_pass methods: */
virtual bool gate (function *)
{
- return flag_cilkplus || flag_openacc || flag_openmp;
+ return flag_cilkplus || flag_openacc || flag_openmp || flag_openmp_simd;
}
virtual unsigned int execute (function *)
{
--- gcc/testsuite/c-c++-common/pr81052.c.jj 2017-08-02 12:59:28.092223248 +0200
+++ gcc/testsuite/c-c++-common/pr81052.c 2017-08-02 13:00:30.603510773 +0200
@@ -0,0 +1,28 @@
+/* PR middle-end/81052 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd -O2" } */
+
+int
+foo (int x, int y)
+{
+ int i;
+#pragma omp simd
+ for (i = x; i < y; ++i)
+ return 0; /* { dg-error "invalid branch to/from OpenMP structured block" } */
+ return 1;
+}
+
+#ifdef __cplusplus
+template <typename T>
+T
+bar (T x, T y)
+{
+ T i;
+#pragma omp simd
+ for (i = x; i < y; ++i)
+ return 0; /* { dg-error "invalid branch to/from OpenMP structured block" "" { target c++ } } */
+ return 1;
+}
+
+int x = bar (1, 7);
+#endif
Jakub
More information about the Gcc-patches
mailing list