1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-isolate-paths -fdelete-null-pointer-checks -Wnull-dereference" } */
3 /* { dg-skip-if "" keeps_null_pointer_checks } */
4
5
6 typedef __SIZE_TYPE__ size_t;
7 extern void *memset (void *__s, int __c, size_t __n)
8 __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__nonnull__ (1)));
9 struct rtx_def;
10 typedef struct rtx_def *rtx;
11 typedef struct VEC_rtx_base
12
13 {
14 unsigned num;
15 unsigned alloc;
16 rtx vec[1];
17 } VEC_rtx_base;
18 static __inline__ rtx *
VEC_rtx_base_address(VEC_rtx_base * vec_)19 VEC_rtx_base_address (VEC_rtx_base * vec_)
20 {
21 return vec_ ? vec_->vec : 0;
22 }
23 typedef struct VEC_rtx_gc
24 {
25 VEC_rtx_base base;
26 } VEC_rtx_gc;
27
28 static __inline__ void
VEC_rtx_gc_safe_grow(VEC_rtx_gc ** vec_,int size_,const char * file_,unsigned line_,const char * function_)29 VEC_rtx_gc_safe_grow (VEC_rtx_gc ** vec_, int size_, const char *file_,
30 unsigned line_, const char *function_)
31 {
32 ((*vec_) ? &(*vec_)->base : 0)->num = size_; /* { dg-warning "null pointer dereference" } */
33 }
34
35 static __inline__ void
VEC_rtx_gc_safe_grow_cleared(VEC_rtx_gc ** vec_,int size_,const char * file_,unsigned line_,const char * function_,int oldsize)36 VEC_rtx_gc_safe_grow_cleared (VEC_rtx_gc ** vec_, int size_,
37 const char *file_, unsigned line_,
38 const char *function_, int oldsize)
39 {
40 VEC_rtx_gc_safe_grow (vec_, size_, file_, line_, function_);
41 memset (&(VEC_rtx_base_address ((*vec_) ? &(*vec_)->base : 0))[oldsize], 0,
42 sizeof (rtx) * (size_ - oldsize));
43 }
44
45 static VEC_rtx_gc *reg_base_value;
46 unsigned int max_reg_num (void);
47 int arf (void);
48 void
init_alias_analysis(void)49 init_alias_analysis (void)
50 {
51 unsigned int maxreg = max_reg_num ();
52 (VEC_rtx_gc_safe_grow_cleared
53 (&(reg_base_value), maxreg, "../../../gcc-4.6.0/gcc/alias.c", 2755,
54 __FUNCTION__, arf ()));
55 }
56
57
58
59 /* This is an example of how a NULL pointer dereference can show up
60 without a PHI. Note VEC_rtx_gcc_safe_grow. If an earlier pass
61 (such as VRP) isolates the NULL path for some reason or another
62 we end up with an explicit NULL dereference in the IL. Yes, it
63 started with a PHI, but by the time the path isolation code runs
64 its explicit in the IL. */
65 /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "isolate-paths"} } */
66
67
68