[PATCH] Fix Cilk+ ICEs with overflow builtins (PR middle-end/63884)

2014-11-15 Thread Marek Polacek
The problem here is that the Cilk+ code wasn't prepared to handle
internal calls that the new overflow builtins entail.  Fixed by
checking that the CALL_EXPR_FN isn't NULL.

Looking at cilk-plus.exp, I think this file will need some tweaks
now that the C default is gnu11...

Bootstrapped/regtested on powerpc64-linux, ok for trunk?

2014-11-15  Marek Polacek  pola...@redhat.com

PR middle-end/63884
c-family/
* array-notation-common.c (is_sec_implicit_index_fn): Return false
for NULL fndecl.
(extract_array_notation_exprs): Return for NULL node.
testsuite/
* c-c++-common/cilk-plus/AN/pr63884.c: New test.

diff --git gcc/c-family/array-notation-common.c 
gcc/c-family/array-notation-common.c
index f8bce04..cb5708c 100644
--- gcc/c-family/array-notation-common.c
+++ gcc/c-family/array-notation-common.c
@@ -35,6 +35,9 @@ along with GCC; see the file COPYING3.  If not see
 bool
 is_sec_implicit_index_fn (tree fndecl)
 {
+  if (!fndecl)
+return false;
+
   if (TREE_CODE (fndecl) == ADDR_EXPR)
 fndecl = TREE_OPERAND (fndecl, 0);
 
@@ -327,6 +330,9 @@ extract_array_notation_exprs (tree node, bool 
ignore_builtin_fn,
  vectree, va_gc **array_list)
 {
   size_t ii = 0;  
+
+  if (!node)
+return;
   if (TREE_CODE (node) == ARRAY_NOTATION_REF)
 {
   vec_safe_push (*array_list, node);
diff --git gcc/testsuite/c-c++-common/cilk-plus/AN/pr63884.c 
gcc/testsuite/c-c++-common/cilk-plus/AN/pr63884.c
index e69de29..c876a8d 100644
--- gcc/testsuite/c-c++-common/cilk-plus/AN/pr63884.c
+++ gcc/testsuite/c-c++-common/cilk-plus/AN/pr63884.c
@@ -0,0 +1,10 @@
+/* PR middle-end/63884 */
+/* { dg-do compile } */
+/* { dg-options -fcilkplus } */
+
+int
+foo (int x, int y)
+{
+  int r;
+  return __builtin_sadd_overflow (x, y, r);
+}

Marek


Re: [PATCH] Fix Cilk+ ICEs with overflow builtins (PR middle-end/63884)

2014-11-15 Thread Jakub Jelinek
On Sat, Nov 15, 2014 at 01:03:46PM +0100, Marek Polacek wrote:
 The problem here is that the Cilk+ code wasn't prepared to handle
 internal calls that the new overflow builtins entail.  Fixed by
 checking that the CALL_EXPR_FN isn't NULL.
 
 Looking at cilk-plus.exp, I think this file will need some tweaks
 now that the C default is gnu11...
 
 Bootstrapped/regtested on powerpc64-linux, ok for trunk?
 
 2014-11-15  Marek Polacek  pola...@redhat.com
 
   PR middle-end/63884
 c-family/
   * array-notation-common.c (is_sec_implicit_index_fn): Return false
   for NULL fndecl.
   (extract_array_notation_exprs): Return for NULL node.
 testsuite/
   * c-c++-common/cilk-plus/AN/pr63884.c: New test.

Ok, thanks.

Jakub