1 #include "../../gcc.dg/analyzer/analyzer-decls.h"
4 /* Verify that the analyzer makes the simplifying assumption that we don't
5 hit NULL when incrementing pointers to non-NULL memory regions. */
7 static int * __attribute__((noinline
))
8 maybe_inc_int_ptr (int *ptr
)
20 a
= maybe_inc_int_ptr (a
);
21 a
= maybe_inc_int_ptr (a
);
22 __analyzer_eval (a
== NULL
); /* { dg-warning "FALSE" } */
23 __analyzer_eval (a
!= NULL
); /* { dg-warning "TRUE" } */
24 return *a
; /* { dg-line test_1 } */
26 /* { dg-warning "stack-based buffer over-read" "warning" { target *-*-* } test_1 } */
29 static const char * __attribute__((noinline
))
30 maybe_inc_char_ptr (const char *ptr
)
40 const char *msg
= "hello world";
42 __analyzer_eval (*a
== 'h'); /* { dg-warning "TRUE" } */
43 a
= maybe_inc_char_ptr (a
);
44 __analyzer_eval (*a
== 'e'); /* { dg-warning "TRUE" } */
45 a
= maybe_inc_char_ptr (a
);
46 __analyzer_eval (*a
== 'l'); /* { dg-warning "TRUE" } */
47 a
= maybe_inc_char_ptr (a
);
48 __analyzer_eval (*a
== 'l'); /* { dg-warning "TRUE" } */
49 a
= maybe_inc_char_ptr (a
);
50 __analyzer_eval (*a
== 'o'); /* { dg-warning "TRUE" } */