re PR middle-end/26092 (ICE on const function pointer assigned to a builtin function)
authorJakub Jelinek <jakub@redhat.com>
Mon, 13 Feb 2006 21:28:03 +0000 (22:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 13 Feb 2006 21:28:03 +0000 (22:28 +0100)
PR middle-end/26092
* gimplify.c (gimplify_call_expr): Don't call get_callee_fndecl
twice if decl is a builtin.  When trying again, call get_callee_fndecl
first to verify it is still a builtin.

* gcc.c-torture/compile/20060208-1.c: New test.

From-SVN: r110927

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20060208-1.c [new file with mode: 0644]

index 15c3fc47c19500ffd6967f160e245f3a56e4fc3e..46d5b68e37b9d953d38817fbd74b0864581950ec 100644 (file)
@@ -1,3 +1,10 @@
+2006-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/26092
+       * gimplify.c (gimplify_call_expr): Don't call get_callee_fndecl
+       twice if decl is a builtin.  When trying again, call get_callee_fndecl
+       first to verify it is still a builtin.
+
 2006-02-13  Geoffrey Keating  <geoffk@apple.com>
 
        * dwarf2out.c (base_type_die): Don't add AT_name here.
index 710569888ec32e50ff31adb4683fb4ee1f2a152f..82e747f00709d7e6fc97c5deb56c028980262f3e 100644 (file)
@@ -1970,9 +1970,8 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
   decl = get_callee_fndecl (*expr_p);
   if (decl && DECL_BUILT_IN (decl))
     {
-      tree fndecl = get_callee_fndecl (*expr_p);
       tree arglist = TREE_OPERAND (*expr_p, 1);
-      tree new = fold_builtin (fndecl, arglist, !want_value);
+      tree new = fold_builtin (decl, arglist, !want_value);
 
       if (new && new != *expr_p)
        {
@@ -2026,19 +2025,22 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
     TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
 
   /* Try this again in case gimplification exposed something.  */
-  if (ret != GS_ERROR && decl && DECL_BUILT_IN (decl))
+  if (ret != GS_ERROR)
     {
-      tree fndecl = get_callee_fndecl (*expr_p);
-      tree arglist = TREE_OPERAND (*expr_p, 1);
-      tree new = fold_builtin (fndecl, arglist, !want_value);
-
-      if (new && new != *expr_p)
+      decl = get_callee_fndecl (*expr_p);
+      if (decl && DECL_BUILT_IN (decl))
        {
-         /* There was a transformation of this call which computes the
-            same value, but in a more efficient way.  Return and try
-            again.  */
-         *expr_p = new;
-         return GS_OK;
+         tree arglist = TREE_OPERAND (*expr_p, 1);
+         tree new = fold_builtin (decl, arglist, !want_value);
+
+         if (new && new != *expr_p)
+           {
+             /* There was a transformation of this call which computes the
+                same value, but in a more efficient way.  Return and try
+                again.  */
+             *expr_p = new;
+             return GS_OK;
+           }
        }
     }
 
index 113914077f7bf3cf8999105867155460cde73b3e..1f2fdb7e55f172fd78b6d72f3fcc709e0682cfbe 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/26092
+       * gcc.c-torture/compile/20060208-1.c: New test.
+
 2006-02-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/26074
diff --git a/gcc/testsuite/gcc.c-torture/compile/20060208-1.c b/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
new file mode 100644 (file)
index 0000000..01e471a
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR middle-end/26092 */
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc (size_t);
+
+void *(*const foo) (size_t) = malloc;
+
+void *test (void)
+{
+  return (*foo) (3);
+}