From a5c8d67f10eb90a6f2eff58e50c9ee90d401eb56 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 23 Feb 2006 19:06:21 +0100 Subject: [PATCH] re PR middle-end/26412 (ICE with external arrays using OpenMP) PR middle-end/26412 * gimplify.c (omp_add_variable): Guard variable size decl test with DECL_SIZE (decl) check. * gcc.dg/gomp/pr26412.c: New test. From-SVN: r111391 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/gomp/pr26412.c | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr26412.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b04c5782bbe..1f81c5b2d30 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-02-23 Jakub Jelinek + + PR middle-end/26412 + * gimplify.c (omp_add_variable): Guard variable size decl test with + DECL_SIZE (decl) check. + 2006-02-23 Richard Guenther PR middle-end/26439 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 82e747f0070..10373c2d92f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4267,7 +4267,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags) /* When adding a variable-sized variable, we have to handle all sorts of additional bits of data: the pointer replacement variable, and the parameters of the type. */ - if (!TREE_CONSTANT (DECL_SIZE (decl))) + if (DECL_SIZE (decl) && !TREE_CONSTANT (DECL_SIZE (decl))) { /* Add the pointer replacement variable as PRIVATE if the variable replacement is private, else FIRSTPRIVATE since we'll need the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 951bc113265..3d359f12314 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-02-23 Jakub Jelinek + + PR middle-end/26412 + * gcc.dg/gomp/pr26412.c: New test. + 2006-02-22 Volker Reichelt PR c++/26291 diff --git a/gcc/testsuite/gcc.dg/gomp/pr26412.c b/gcc/testsuite/gcc.dg/gomp/pr26412.c new file mode 100644 index 00000000000..6baecfe6895 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr26412.c @@ -0,0 +1,18 @@ +/* PR middle-end/26412 */ +/* { dg-do compile } */ + +extern double a[]; +extern int b; + +double +test (void) +{ + int i; + double c = 0; + +#pragma omp parallel for private(i) reduction(+:c) + for (i = 0; i < 10000; i++) + c += a[b]; + + return c; +}