re PR tree-optimization/16115 (double-destruction problem with argument passing via temporary (breaks auto_ptr))
PR c++/16115 * decl.c (grokparms): Give the PARM_DECL reference type if the parameter is passed by invisible reference. From-SVN: r83609
This commit is contained in:
parent
de7c79cc77
commit
3db4a9b428
@ -1,3 +1,9 @@
|
||||
2004-06-24 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/16115
|
||||
* decl.c (grokparms): Give the PARM_DECL reference type if the
|
||||
parameter is passed by invisible reference.
|
||||
|
||||
2004-06-24 Andreas Schwab <schwab@suse.de>
|
||||
|
||||
* cp-tree.h (enum cp_storage_class): Remove trailing comma.
|
||||
|
@ -8224,6 +8224,13 @@ grokparms (cp_parameter_declarator *first_parm, tree *parms)
|
||||
|
||||
if (type != error_mark_node)
|
||||
{
|
||||
/* If this type is passed by invisible reference, make the PARM_DECL
|
||||
reflect that so that alias analysis knows that the actual object
|
||||
is external to the function. */
|
||||
if (TREE_ADDRESSABLE (type))
|
||||
decl = build_decl (PARM_DECL, DECL_NAME (decl),
|
||||
build_reference_type (type));
|
||||
|
||||
/* Top-level qualifiers on the parameters are
|
||||
ignored for function types. */
|
||||
type = cp_build_qualified_type (type, 0);
|
||||
@ -8258,7 +8265,7 @@ grokparms (cp_parameter_declarator *first_parm, tree *parms)
|
||||
}
|
||||
|
||||
if (!any_error && init)
|
||||
init = check_default_argument (decl, init);
|
||||
init = check_default_argument (type, init);
|
||||
else
|
||||
init = NULL_TREE;
|
||||
}
|
||||
|
35
gcc/testsuite/g++.dg/init/call1.C
Normal file
35
gcc/testsuite/g++.dg/init/call1.C
Normal file
@ -0,0 +1,35 @@
|
||||
// Bug c++/16115
|
||||
// { dg-do run }
|
||||
|
||||
extern "C" void abort();
|
||||
|
||||
int count = 0;
|
||||
|
||||
struct T {
|
||||
T() { count++; }
|
||||
T(const T&) { count++; }
|
||||
~T() { if (count==0) abort(); --count; }
|
||||
};
|
||||
|
||||
struct auto_ptr {
|
||||
T* p;
|
||||
|
||||
auto_ptr(T* __p) : p(__p) { }
|
||||
~auto_ptr() { delete p; }
|
||||
|
||||
T* release() {
|
||||
T* t = p;
|
||||
p = 0;
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
void destroy (auto_ptr a) {
|
||||
delete a.release();
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
destroy (new T);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user