===================================================================
@@ -3078,7 +3078,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree
{
tree virtual_size;
tree ptype = build_pointer_type (type = complete_type (type));
- tree size_exp = size_in_bytes (type);
+ tree size_exp;
/* Temporary variables used by the loop. */
tree tbase, tbase_init;
@@ -3106,6 +3106,22 @@ build_vec_delete_1 (tree base, tree maxindex, tree
if (base == error_mark_node || maxindex == error_mark_node)
return error_mark_node;
+ if (!COMPLETE_TYPE_P (type))
+ {
+ if ((complain & tf_warning)
+ && warning (0, "possible problem detected in invocation of "
+ "delete [] operator:"))
+ {
+ cxx_incomplete_type_diagnostic (base, type, DK_WARNING);
+ inform (input_location, "neither the destructor nor the "
+ "class-specific operator delete [] will be called, "
+ "even if they are declared when the class is defined");
+ }
+ return build_builtin_delete_call (base);
+ }
+
+ size_exp = size_in_bytes (type);
+
if (! MAYBE_CLASS_TYPE_P (type) || TYPE_HAS_TRIVIAL_DESTRUCTOR (type))
goto no_destructor;
===================================================================
@@ -1,7 +1,7 @@
// PR c++/19811
-class C; // { dg-error "forward" }
+class C; // { dg-warning "forward" }
void foo(void *p) {
- delete [] ((C*)p) ; // { dg-error "" }
+ delete [] ((C*)p) ; // { dg-warning "problem|incomplete" }
}