Since Jakub's P2795R5 work removes the initial clobber from constructors,
let's add a clobber for new of all non-empty classes.
gcc/cp/ChangeLog:
* init.cc (build_new_1): Clobber classes.
gcc/testsuite/ChangeLog:
* g++.dg/analyzer/pr97116.C: Adjust diagnostic.
* g++.dg/warn/Warray-bounds-20.C: Likewise.
= (std_placement && flag_lifetime_dse > 1
&& !processing_template_decl
&& !is_empty_type (elt_type)
- && !*init
- && (!CLASS_TYPE_P (elt_type)
- || type_has_non_user_provided_default_constructor (elt_type)));
+ && (!*init || CLASS_TYPE_P (elt_type)));
/* In the simple case, we can stop now. */
pointer_type = build_pointer_type (type);
struct foo
{
- foo (int i) : m_i (i) {} // { dg-message "argument 'this' of 'foo::foo\\(int\\)' must be non-null" "note" }
+ foo (int i) : m_i (i) {}
int get () const { return m_i; } // { dg-message "argument 'this' of '\[^\n\]*' must be non-null" "note" }
void test_1 (void)
{
- foo *p = new(NULL) foo (42); // { dg-warning "non-null expected" "warning" }
- // { dg-message "argument 'this'( \\(\[^\n\]*\\))? NULL where non-null expected" "final event" { target *-*-* } .-1 }
+ foo *p = new(NULL) foo (42); // { dg-warning "dereference of NULL" "warning" }
}
int test_2 (void)
// { dg-message "at offset 1 into object 'a' of size 20" "LP64 note" { target ilp32} .-1 }
char *p = a;
++p;
- D1 *q = new (p) D1;
+ D1 *q = new (p) D1; // { dg-warning "-Warray-bounds" }
sink (q);
}
{
char *p = (char*)operator new (sizeof (D1)); // { dg-message "at offset 1 into object of size \\d+ allocated by '\[^\n\r]*operator new\[^\n\r]*'" "note" }
++p;
- D1 *q = new (p) D1;
+ D1 *q = new (p) D1; // { dg-warning "-Warray-bounds" }
sink (q);
}