From: Jakub Jelinek Date: Thu, 10 Sep 2015 07:35:56 +0000 (+0200) Subject: re PR c++/67523 (ICE with invalid combined simd inside of a template) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ce1688bb8b00bafc041e375b453d9f957cc1424;p=gcc.git re PR c++/67523 (ICE with invalid combined simd inside of a template) PR c++/67523 * gimplify.c (gimplify_omp_for): If inner stmt is not found for combined loop, assert seen_error () and return GS_ERROR. * g++.dg/gomp/pr67523.C: New test. From-SVN: r227611 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3be0e0aef75..fb9bbb787dc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2015-09-10 Jakub Jelinek + PR c++/67523 + * gimplify.c (gimplify_omp_for): If inner stmt is not found + for combined loop, assert seen_error () and return GS_ERROR. + PR middle-end/67521 * gimplify.c (gimplify_omp_for): Don't call omp_add_variable if decl is already in outer->variables. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 5030318ddc8..10f84d47ec2 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -7001,7 +7001,7 @@ find_combined_omp_for (tree *tp, int *walk_subtrees, void *) static enum gimplify_status gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { - tree for_stmt, orig_for_stmt, decl, var, t; + tree for_stmt, orig_for_stmt, inner_for_stmt = NULL_TREE, decl, var, t; enum gimplify_status ret = GS_ALL_DONE; enum gimplify_status tret; gomp_for *gfor; @@ -7044,6 +7044,19 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) } } + if (OMP_FOR_INIT (for_stmt) == NULL_TREE) + { + gcc_assert (TREE_CODE (for_stmt) != OACC_LOOP); + inner_for_stmt = walk_tree (&OMP_FOR_BODY (for_stmt), + find_combined_omp_for, NULL, NULL); + if (inner_for_stmt == NULL_TREE) + { + gcc_assert (seen_error ()); + *expr_p = NULL_TREE; + return GS_ERROR; + } + } + gimplify_scan_omp_clauses (&OMP_FOR_CLAUSES (for_stmt), pre_p, simd ? ORT_SIMD : ORT_WORKSHARE); if (TREE_CODE (for_stmt) == OMP_DISTRIBUTE) @@ -7079,10 +7092,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) if (OMP_FOR_INIT (for_stmt) == NULL_TREE) { - gcc_assert (TREE_CODE (for_stmt) != OACC_LOOP); - for_stmt = walk_tree (&OMP_FOR_BODY (for_stmt), find_combined_omp_for, - NULL, NULL); - gcc_assert (for_stmt != NULL_TREE); + for_stmt = inner_for_stmt; gimplify_omp_ctxp->combined_loop = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d1d4cd4671a..8a06e5169d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-09-10 Jakub Jelinek + PR c++/67523 + * g++.dg/gomp/pr67523.C: New test. + PR c++/67522 * g++.dg/gomp/pr67522.C: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr67523.C b/gcc/testsuite/g++.dg/gomp/pr67523.C new file mode 100644 index 00000000000..fb12c8c4695 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr67523.C @@ -0,0 +1,29 @@ +// PR c++/67523 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct S { int s; }; + +template +void foo (T &x, T &y) +{ +#pragma omp for simd + for (T i = x; i < y; i++) // { dg-error "used with class iteration variable" } + ; +#pragma omp parallel for simd + for (T i = x; i < y; i++) // { dg-error "used with class iteration variable" } + ; +#pragma omp target teams distribute parallel for simd + for (T i = x; i < y; i++) // { dg-error "used with class iteration variable" } + ; +#pragma omp target teams distribute simd + for (T i = x; i < y; i++) // { dg-error "used with class iteration variable" } + ; +} + +void +bar () +{ + S x, y; + foo (x, y); +}