+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.
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);
}
if (!any_error && init)
- init = check_default_argument (decl, init);
+ init = check_default_argument (type, init);
else
init = NULL_TREE;
}
--- /dev/null
+// 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);
+}