* [committed] Diagnose invalid #pragma omp simd even for -fopenmp-simd (PR middle-end/81052)
@ 2017-08-03 8:37 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2017-08-03 8:37 UTC (permalink / raw)
To: gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-03 8:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 8:37 [committed] Diagnose invalid #pragma omp simd even for -fopenmp-simd (PR middle-end/81052) Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).