re PR c++/15759 (ICE with function pointers)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 6 Mar 2006 02:01:29 +0000 (02:01 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 6 Mar 2006 02:01:29 +0000 (02:01 +0000)
PR c++/15759
* tree.c (bot_manip): Don't call mark_used.

* g++.dg/other/default4.C: New test.

From-SVN: r111754

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/default4.C [new file with mode: 0644]

index f0d1301b7c57e2021a847a576c699de44a79d452..4c735d74c0b6ab7117a05f47600bb60086f56823 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/15759
+       * tree.c (bot_manip): Don't call mark_used.
+
 2006-03-02  Mike Stump  <mrs@apple.com>
 
        * decl2.c (import_export_decl): Remove redundant call to
index 16e87ec2d63e0e9df9ff2e719412381faa9e49c3..d58b5b350dda768be502a5ee12c01604698740a5 100644 (file)
@@ -1173,16 +1173,11 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
       tree u;
 
       if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
-       {
-         mark_used (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 1), 0), 0));
-         u = build_cplus_new
-           (TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
-       }
+       u = build_cplus_new
+         (TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
       else
-       {
-         u = build_target_expr_with_type
-           (break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
-       }
+       u = build_target_expr_with_type
+         (break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
 
       /* Map the old variable to the new one.  */
       splay_tree_insert (target_remap,
@@ -1197,8 +1192,6 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
       *walk_subtrees = 0;
       return NULL_TREE;
     }
-  else if (TREE_CODE (t) == CALL_EXPR)
-    mark_used (TREE_OPERAND (TREE_OPERAND (t, 0), 0));
 
   /* Make a copy of this node.  */
   return copy_tree_r (tp, walk_subtrees, NULL);
index d38d9599825c1ce175ee0ce9b6dcc60a12fcd12c..3d5f444ceeac8a346ffe7350d15a70ecd2df5cc6 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/15759
+       * g++.dg/other/default4.C: New test.
+
 2005-03-05  Erik Edelmann  <eedelman@gcc.gnu.org>
 
        PR fortran/16136
diff --git a/gcc/testsuite/g++.dg/other/default4.C b/gcc/testsuite/g++.dg/other/default4.C
new file mode 100644 (file)
index 0000000..5994809
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/15759
+// Origin:   Lars Rune Nøstdal  <larsnostdal@gmail.com>
+// Testcase: Volker Reichelt    <reichelt@igpm.rwth-aachen.de>
+
+// { dg-do run }
+
+extern "C" void abort();
+
+int n = 0;
+
+int f() { return ++n; }
+
+int(&foo1)() = f;
+int(*foo2)() = &f;
+int(*foo3)() = f;
+
+int bar1(int i = foo1()) { return i; }
+int bar2(int i = foo2()) { return i; }
+int bar3(int i = foo3()) { return i; }
+int bar4(int i = f())    { return i; }
+
+int main()
+{
+  if (bar1() != 1) abort();
+  if (bar2() != 2) abort();
+  if (bar3() != 3) abort();
+  if (bar4() != 4) abort();
+  return 0;
+}