re PR c++/30108 (internal compiler error: in make_decl_rtl, at varasm.c:890)
authorMark Mitchell <mark@codesourcery.com>
Mon, 12 Mar 2007 16:24:18 +0000 (16:24 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 12 Mar 2007 16:24:18 +0000 (16:24 +0000)
PR c++/30108
* call.c (convert_default_arg): Copy non-constant arguments.

PR c++/30108
* g++.dg/other/default6.C: New test.

From-SVN: r122844

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

index acc64352947e4f00f02d20b18bb5d2fbb20542b0..ccbb842d2fe3ee35ded239d325f9dca2b52951d1 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/30108
+       * call.c (convert_default_arg): Copy non-constant arguments.
+
 2007-03-11  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/31038
index 637671bc1bcba87f683807fb1bbebda41a9f97cc..00e0c063e862bbea62597c4b59a5b55f37c0654c 100644 (file)
@@ -4664,10 +4664,14 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
     }
   else
     {
-      /* This could get clobbered by the following call.  */
-      if (TREE_HAS_CONSTRUCTOR (arg))
+      /* We must make a copy of ARG, in case subsequent processing
+        alters any part of it.  For example, during gimplification a
+        cast of the form (T) &X::f (where "f" is a member function)
+        will lead to replacing the PTRMEM_CST for &X::f with a
+        VAR_DECL.  We can avoid the copy for constants, since they
+        are never modified in place.  */
+      if (!CONSTANT_CLASS_P (arg))
        arg = copy_node (arg);
-
       arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL,
                                        "default argument", fn, parmnum);
       arg = convert_for_arg_passing (type, arg);
index 2c3f7d8dcb410ca94d02c4894fec0f08f4c565a5..9d0a8df6333a46023764538fd3f59ffe12e0526b 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/30108
+       * g++.dg/other/default6.C: New test.
+
 2007-03-12  Richard Sandiford  <richard@codesourcery.com>
 
        * lib/target-supports.exp (check_profiling_available): Return false
diff --git a/gcc/testsuite/g++.dg/other/default6.C b/gcc/testsuite/g++.dg/other/default6.C
new file mode 100644 (file)
index 0000000..2641801
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/30108
+
+class BaseRobot {
+  typedef void (BaseRobot::*PseudoState)(void);
+  typedef PseudoState STATE;
+  STATE initial ();
+  int ready ();
+  STATE stpOtherTask ();
+  STATE commonEventProcessing (STATE pIdleTarget=(STATE)&BaseRobot::ready);
+};
+BaseRobot::STATE BaseRobot::initial ()
+{
+  return commonEventProcessing ();
+}
+BaseRobot::STATE BaseRobot::stpOtherTask ()
+{
+  return commonEventProcessing ();
+}