OSDN Git Service

2007-03-14 Andrew Pinski <andrew_pinski@playstation.sony.com>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Mar 2007 01:27:29 +0000 (01:27 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Mar 2007 01:27:29 +0000 (01:27 +0000)
        PR c++/31165
        * call.c  (convert_default_arg): Instead of copying the node,
        unshare it.
2007-03-14  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/31165
        * g++.dg/other/default7.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122941 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2142ac4..7d10b2d 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-14  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR c++/31165
+       * call.c  (convert_default_arg): Instead of copying the node,
+       unshare it.
+
 2007-03-15  Dirk Mueller  <dmueller@suse.de>
 
        PR c++/30860
index 53129bb..9d25298 100644 (file)
@@ -4683,7 +4683,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
         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 = unshare_expr (arg);
       arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL,
                                        "default argument", fn, parmnum);
       arg = convert_for_arg_passing (type, arg);
index 27974a9..47d9770 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-14  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/31165
+       * g++.dg/other/default7.C: New test.
+
 2007-03-15  Dirk Mueller  <dmueller@suse.de>
 
        * g++.dg/warn/Wconversion2.C: New.
diff --git a/gcc/testsuite/g++.dg/other/default7.C b/gcc/testsuite/g++.dg/other/default7.C
new file mode 100644 (file)
index 0000000..ec523bf
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do assemble } */
+/* { dg-options "-O1" }*/
+// This was PR C++/31165
+// We used to copy the whole decl when we just wantted to
+// unshare some expressions for the default argument.
+class string {
+  char *ptr;
+  int len;
+  int sz;
+};
+class cset { }  _cset_init;
+string an_empty_string;
+void f(string& = an_empty_string);
+void
+h (void )
+{
+f();
+}
+
+