Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / analyzer / pr97116.C
blob1c404c2ceb233f0009dee3700d45d51d2eb90c0f
1 #include <new>
2 #include <cstddef>
4 struct foo
6   foo (int i) : m_i (i) {} // { dg-message "argument 'this' of 'foo::foo\\(int\\)' must be non-null" "note" }
8   int get () const { return m_i; } // { dg-message "argument 'this' of '\[^\n\]*' must be non-null" "note" }
9   
10   int meth_1 (int, void *ptr) __attribute__((nonnull)); // { dg-message "argument 2 of '\[^\n\]*' must be non-null" "note" }
11   int meth_2 (int, void *ptr) __attribute__((nonnull(3))); // { dg-message "argument 2 of '\[^\n\]*' must be non-null" "note" }
13   int m_i;
16 void test_1 (void)
18   foo *p = new(NULL) foo (42); // { dg-warning "non-null expected" "warning" }
19   // { dg-message "argument 'this'( \\(\[^\n\]*\\))? NULL where non-null expected" "final event" { target *-*-* } .-1 }
22 int test_2 (void)
24   foo *p = NULL;
25   return p->get (); // { dg-warning "non-null expected" "warning" }
26   // { dg-message "argument 'this' \\('p'\\) NULL where non-null expected" "final event" { target *-*-* } .-1 }
29 int test_meth_1 (foo *f)
31   return f->meth_1 (42, NULL); // { dg-warning "non-null expected" "warning" }
32   // { dg-message "argument 2 NULL where non-null expected" "final event" { target *-*-* } .-1 }
35 int test_meth_2 (foo *f)
37   return f->meth_2 (42, NULL); // { dg-warning "non-null expected" "warning" }
38   // { dg-message "argument 2 NULL where non-null expected" "final event" { target *-*-* } .-1 }