re PR c++/31165 (Error: symbol `an_empty_string' is already defined)

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-14  Andrew Pinski  <andrew_pinski@playstation.sony.com>

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

From-SVN: r122941
This commit is contained in:
Andrew Pinski 2007-03-15 01:27:29 +00:00 committed by Andrew Pinski
parent 22cbc70726
commit 344bd5a861
4 changed files with 32 additions and 1 deletions

View 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

View 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);

View 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.

View File

@ -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();
}