aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-04-15 14:24:18 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-04-15 14:24:18 +0200
commitdda1bf6123a4e69cb9aa5072442b803f82da2be3 (patch)
tree1a0514ea3a8182e7b4be92bcb5f3ff6734da03f9 /gcc/testsuite/c-c++-common
parent60cbb674776db42617d6f66487ff4074ee7862ba (diff)
downloadgcc-dda1bf6123a4e69cb9aa5072442b803f82da2be3.zip
gcc-dda1bf6123a4e69cb9aa5072442b803f82da2be3.tar.gz
gcc-dda1bf6123a4e69cb9aa5072442b803f82da2be3.tar.bz2
re PR c/70436 (-Wparentheses missing ambiguous else warning)
PR c/70436 c/ * c-parser.c (c_parser_pragma): Add IF_P argument, pass it down where needed. (c_parser_external_declaration, c_parser_struct_or_union_specifier, c_parser_parameter_declaration, c_parser_compound_statement_nostart, c_parser_objc_class_instance_variables, c_parser_objc_methodprotolist): Adjust c_parser_pragma callers. (c_parser_statement_after_labels): Likewise. Adjust c_parser_cilk_for caller. (c_parser_omp_structured_block): Add IF_P argument, pass it down to c_parser_statement. (c_parser_oacc_data, c_parser_oacc_host_data, c_parser_oacc_loop, c_parser_oacc_kernels_parallel, c_parser_omp_critical, c_parser_omp_simd, c_parser_omp_for, c_parser_omp_master, c_parser_omp_ordered, c_parser_omp_parallel, c_parser_omp_single, c_parser_omp_task, c_parser_omp_taskgroup, c_parser_omp_distribute, c_parser_omp_teams, c_parser_omp_target_data, c_parser_omp_target, c_parser_omp_taskloop, c_parser_omp_construct, c_parser_cilk_grainsize, c_parser_cilk_simd, c_parser_cilk_for): Add IF_P argument, pass it down where needed. (c_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. (c_parser_omp_sections_scope): Adjust c_parser_omp_structured_block calls. cp/ * parser.c (cp_parser_pragma): Add IF_P argument, pass it down where needed. (cp_parser_declaration_seq_opt, cp_parser_member_specification_opt, cp_parser_objc_interstitial_code, cp_parser_omp_declare_simd, cp_parser_oacc_routine): Adjust cp_parser_pragma callers. (cp_parser_statement): Likewise. Adjust cp_parser_cilk_for caller. (cp_parser_omp_structured_block): Add IF_P argument, pass it down to cp_parser_statement. (cp_parser_oacc_data, cp_parser_oacc_host_data, cp_parser_oacc_loop, cp_parser_oacc_kernels_parallel, cp_parser_omp_critical, cp_parser_omp_simd, cp_parser_omp_for, cp_parser_omp_master, cp_parser_omp_ordered, cp_parser_omp_parallel, cp_parser_omp_single, cp_parser_omp_task, cp_parser_omp_taskgroup, cp_parser_omp_distribute, cp_parser_omp_teams, cp_parser_omp_target_data, cp_parser_omp_target, cp_parser_omp_taskloop, cp_parser_omp_construct, cp_parser_cilk_grainsize, cp_parser_cilk_simd, cp_parser_cilk_for): Add IF_P argument, pass it down where needed. (cp_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. (cp_parser_omp_sections_scope): Adjust cp_parser_omp_structured_block calls. testsuite/ * c-c++-common/Wparentheses-1.c: New test. * c-c++-common/gomp/Wparentheses-1.c: New test. * c-c++-common/gomp/Wparentheses-2.c: New test. * c-c++-common/gomp/Wparentheses-3.c: New test. * c-c++-common/gomp/Wparentheses-4.c: New test. * c-c++-common/cilk-plus/PS/Wparentheses-1.c: New test. * c-c++-common/cilk-plus/CK/Wparentheses-1.c: New test. * c-c++-common/goacc/Wparentheses-1.c: New test. From-SVN: r235020
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/Wparentheses-1.c39
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c69
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c41
-rw-r--r--gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c174
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c338
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c452
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c338
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c452
8 files changed, 1903 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/Wparentheses-1.c b/gcc/testsuite/c-c++-common/Wparentheses-1.c
new file mode 100644
index 0000000..ed50608
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wparentheses-1.c
@@ -0,0 +1,39 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-Wparentheses" } */
+
+int a, b, c[101], d[101], e[101], f[101];
+
+void
+f1 (void)
+{
+ int i;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ if (b)
+ c[i] = d[i] + e[i];
+ else
+ f[i] = d[i] * e[i];
+
+ if (a)
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ {
+ if (b)
+ c[i] = d[i] + e[i];
+ else
+ f[i] = d[i] * e[i];
+ }
+
+ if (a)
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ {
+ if (b)
+ c[i] = d[i] + e[i];
+ }
+ else
+ f[i] = d[i] * e[i];
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c
new file mode 100644
index 0000000..f07b49a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c
@@ -0,0 +1,69 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus -Wparentheses" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ _Cilk_for (int i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c
new file mode 100644
index 0000000..d391d7b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c
@@ -0,0 +1,41 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus -Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
new file mode 100644
index 0000000..08265b6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
@@ -0,0 +1,174 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+#pragma acc routine
+void bar2 (void);
+#pragma acc routine
+void baz2 (void);
+
+void
+f1 (void)
+{
+ int i, d[10] = { 0 };
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc data copyin (d[0:10])
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ #pragma acc data copyin (d[0:10])
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc host_data use_device (d)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc kernels
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc kernels
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc parallel
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ (void) d[0];
+
+ if (a)
+ #pragma acc data copyin (d[0:10])
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma acc data copyin (d[0:10])
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ #pragma acc data copyin (d[0:10])
+ if (a)
+ #pragma acc host_data use_device (d)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ #pragma acc data copyin (d[0:10])
+ if (a)
+ #pragma acc host_data use_device (d)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma acc kernels
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc kernels
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc parallel
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ {
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+}
+
+#pragma acc routine vector
+void
+f2 (int *a, int b, int c)
+{
+ int i;
+
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ if (c)
+ a[i] = a[i] + 1;
+ else
+ a[i] = a[i] + 2;
+
+ if (b)
+ #pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ {
+ if (c)
+ a[i] = a[i] + 1;
+ else
+ a[i] = a[i] + 2;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c
new file mode 100644
index 0000000..4420d67
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c
@@ -0,0 +1,338 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ while (1)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop
+ for (i = 0; i < 10; i++)
+ if (b)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+ else
+ bar ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp critical
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for simd schedule(runtime)
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp master
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp single
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp task
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskgroup
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp taskloop
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp critical
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for simd schedule(dynamic, 5)
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp master
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp single
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp task
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp taskgroup
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f2 (int d, int e, int f)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (d) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered threads
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (e)
+ #pragma omp ordered
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (f)
+ #pragma omp ordered threads
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c
new file mode 100644
index 0000000..4341b22
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c
@@ -0,0 +1,452 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+void f1 (void);
+#pragma omp declare target to (bar, baz, f1, a, b, c)
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target parallel
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ } }
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ }
+ }
+ else
+ baz ();
+}
+
+void
+f3 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f4 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target data map (tofrom: b)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target data map (tofrom: b)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c
new file mode 100644
index 0000000..1688d10
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c
@@ -0,0 +1,338 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses -fno-openmp" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ while (1)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop
+ for (i = 0; i < 10; i++)
+ if (b)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+ else
+ bar ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp critical
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for simd schedule(runtime)
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp master
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp single
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp task
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskgroup
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp taskloop
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp critical
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for simd schedule(dynamic, 5)
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp master
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp single
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp task
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp taskgroup
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f2 (int d, int e, int f)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (d) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered threads
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (e)
+ #pragma omp ordered
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (f)
+ #pragma omp ordered threads
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c
new file mode 100644
index 0000000..d44cdcd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c
@@ -0,0 +1,452 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses -fno-openmp" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+void f1 (void);
+#pragma omp declare target to (bar, baz, f1, a, b, c)
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target parallel
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ } }
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ }
+ }
+ else
+ baz ();
+}
+
+void
+f3 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f4 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target data map (tofrom: b)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target data map (tofrom: b)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}