2009-11-19 Jason Merrill <jason@redhat.com>
+ PR c++/42115
+ * call.c (build_op_delete_call): Don't complain about using
+ op delete (void *, size_t) for placement delete if there's an
+ op delete (void *).
+
DR 176 permissiveness
* class.c (build_self_reference): Call set_underlying_type.
* decl.c (check_elaborated_type_specifier): Don't complain about
allocation function, the program is ill-formed." */
if (non_placement_deallocation_fn_p (fn))
{
+ /* But if the class has an operator delete (void *), then that is
+ the usual deallocation function, so we shouldn't complain
+ about using the operator delete (void *, size_t). */
+ for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
+ t; t = OVL_NEXT (t))
+ {
+ tree elt = OVL_CURRENT (t);
+ if (non_placement_deallocation_fn_p (elt)
+ && FUNCTION_ARG_CHAIN (elt) == void_list_node)
+ goto ok;
+ }
permerror (0, "non-placement deallocation function %q+D", fn);
permerror (input_location, "selected for placement delete");
+ ok:;
}
}
else
2009-11-19 Jason Merrill <jason@redhat.com>
+ PR c++/42115
+ * g++.dg/init/placement5.C: Add positive test.
+
DR 176 permissiveness
* g++.dg/ext/injected-ttp.C: New.
* g++.old-deja/g++.pt/niklas01a.C: Adjust.
// placement deallocation function, would have been selected as a match for
// the allocation function, the program is ill-formed.
+// But we should only complain about using op delete (void *, size_t) for
+// placement delete if it would also be selected for normal delete, not if
+// there's also an op delete (void *).
+
typedef __SIZE_TYPE__ size_t;
struct A
{
A();
- static void* operator new (size_t, size_t);
- static void operator delete (void *, size_t); // { dg-error "non-placement" }
+ void* operator new (size_t, size_t);
+ void operator delete (void *, size_t); // { dg-error "non-placement" }
+};
+
+struct B
+{
+ B();
+ void * operator new (size_t);
+ void * operator new (size_t, size_t);
+ void operator delete (void *);
+ void operator delete (void *, size_t);
};
int main()
{
A* ap = new (24) A; // { dg-error "placement delete" }
+ B* bp = new (24) B;
}