Hello Everyone, This patch will fix a bug reported in PR57457. One of the array notation function was not checking for NULL_TREE before accessing its fields. This patch should fix that issue. A test case is also added.
Is this OK for trunk? Here are the ChangeLog Entries: gcc/c/ChangeLog 2013-05-31 Balaji V. Iyer <balaji.v.i...@intel.com> * c-array-notation.c (is_cilkplus_reduce_builtin): Added a check for NULL_TREE parameter input. gcc/testsuite/ChangeLog 2013-05-31 Balaji V. Iyer <balaji.v.i...@intel.com> PR c/57457 * c-c++-common/cilk-plus/AN/pr57457.c: New testcase. Thanks, Balaji V. Iyer.
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 828d7c8..e376276 100755 Binary files a/gcc/c/ChangeLog and b/gcc/c/ChangeLog differ diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 681e111..8d43fd9 100755 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -140,6 +140,8 @@ length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) enum built_in_function is_cilkplus_reduce_builtin (tree fndecl) { + if (!fndecl) + return BUILT_IN_NONE; if (TREE_CODE (fndecl) == ADDR_EXPR) fndecl = TREE_OPERAND (fndecl, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20bf8b5..e1339db 100755 Binary files a/gcc/testsuite/ChangeLog and b/gcc/testsuite/ChangeLog differ diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c new file mode 100644 index 0000000..68a1fd8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +/* This test has no array notation components in it and thus should compile + fine without crashing. */ + +typedef unsigned int size_t; +typedef int (*__compar_fn_t) (const void *, const void *); +extern void *bsearch (const void *__key, const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t + __compar) + __attribute__ ((__nonnull__ (1, 2, 5))) ; +extern __inline __attribute__ ((__gnu_inline__)) void * +bsearch (const void *__key, const void *__base, size_t __nmemb, size_t + __size, + __compar_fn_t __compar) +{ + size_t __l, __u, __idx; + const void *__p; + int __comparison; + __l = 0; + __u = __nmemb; + while (__l < __u) + { + __idx = (__l + __u) / 2; + __p = (void *) (((const char *) __base) + + (__idx * __size)); + __comparison = (*__compar) (__key, + __p); + if (__comparison < 0) + __u = __idx; + else if (__comparison > 0) + __l = __idx + 1; + else + return (void *) + __p; + } + return ((void *)0); +}