From: Thomas Schwinge Date: Wed, 12 Feb 2014 14:46:08 +0000 (+0100) Subject: Fix potential ICE (null pointer dereference) in omp-low.c:diagnose_sb_0. X-Git-Tag: releases/gcc-4.9.0~945 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64e5ace535448901c3e29cc1f6612e6c8d2a0a0c;p=thirdparty%2Fgcc.git Fix potential ICE (null pointer dereference) in omp-low.c:diagnose_sb_0. gcc/ * omp-low.c (diagnose_sb_0): Make sure label_ctx is valid to dereference. gcc/testsuite/ * gcc.dg/cilk-plus/jump-openmp.c: New file. From-SVN: r207722 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc720dc04bcf..78bf50692eb3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-02-12 Thomas Schwinge + + * omp-low.c (diagnose_sb_0): Make sure label_ctx is valid to + dereference. + 2014-02-12 James Greenhalgh * config/arm/aarch-cost-tables.h (generic_extra_costs): Fix diff --git a/gcc/omp-low.c b/gcc/omp-low.c index f99b2a62264e..ff3d2e80fb89 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -10269,7 +10269,8 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p, if ((branch_ctx && gimple_code (branch_ctx) == GIMPLE_OMP_FOR && gimple_omp_for_kind (branch_ctx) == GF_OMP_FOR_KIND_CILKSIMD) - || (gimple_code (label_ctx) == GIMPLE_OMP_FOR + || (label_ctx + && gimple_code (label_ctx) == GIMPLE_OMP_FOR && gimple_omp_for_kind (label_ctx) == GF_OMP_FOR_KIND_CILKSIMD)) cilkplus_block = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c87966d3fe73..46d5ff80e532 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-02-12 Thomas Schwinge + + * gcc.dg/cilk-plus/jump-openmp.c: New file. + 2014-02-12 Richard Biener PR middle-end/60092 diff --git a/gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c b/gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c new file mode 100644 index 000000000000..95e6b2d44030 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -fopenmp" } */ +/* { dg-require-effective-target fopenmp } */ + +int *a, *b, c; + +void foo() +{ +#pragma simd + for (int i=0; i < 1000; ++i) + { + a[i] = b[i]; + if (c == 5) + return; /* { dg-error "invalid branch to/from a Cilk Plus structured block" } */ + } +} + +void bar() +{ +#pragma simd + for (int i=0; i < 1000; ++i) + { + lab: + a[i] = b[i]; + } + if (c == 6) + goto lab; /* { dg-error "invalid entry to Cilk Plus structured block" } */ +} + +void baz() +{ + bad1: + #pragma omp parallel + goto bad1; /* { dg-error "invalid branch to/from an OpenMP structured block" } */ + + goto bad2; /* { dg-error "invalid entry to OpenMP structured block" } */ + #pragma omp parallel + { + bad2: ; + } + + #pragma omp parallel + { + int i; + goto ok1; + for (i = 0; i < 10; ++i) + { ok1: break; } + } +}