PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / isolate-3.c
blobd8fd8361ead3bb1cc7dbb915981a34b25d249560
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 } */
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
14 unsigned num;
15 unsigned alloc;
16 rtx vec[1];
17 } VEC_rtx_base;
18 static __inline__ rtx *
19 VEC_rtx_base_address (VEC_rtx_base * vec_)
21 return vec_ ? vec_->vec : 0;
23 typedef struct VEC_rtx_gc
25 VEC_rtx_base base;
26 } VEC_rtx_gc;
28 static __inline__ void
29 VEC_rtx_gc_safe_grow (VEC_rtx_gc ** vec_, int size_, const char *file_,
30 unsigned line_, const char *function_)
32 ((*vec_) ? &(*vec_)->base : 0)->num = size_; /* { dg-warning "null pointer dereference" } */
35 static __inline__ void
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)
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));
45 static VEC_rtx_gc *reg_base_value;
46 unsigned int max_reg_num (void);
47 int arf (void);
48 void
49 init_alias_analysis (void)
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 ()));
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"} } */