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

Marek Polacek polacek@redhat.com
Sat Nov 15 12:34:00 GMT 2014


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  <polacek@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,
 			      vec<tree, 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



More information about the Gcc-patches mailing list