1 extern void abort (void);
2 
3 void __attribute__((noinline,noreturn))
vec_assert_fail(void)4 vec_assert_fail (void)
5 {
6     abort ();
7 }
8 
9 struct ggc_root_tab {
10     void *base;
11 };
12 
13 typedef struct deferred_access_check {} VEC_deferred_access_check_gc;
14 
15 typedef struct deferred_access {
16     VEC_deferred_access_check_gc* deferred_access_checks;
17     int deferring_access_checks_kind;
18 } deferred_access;
19 
20 typedef struct VEC_deferred_access_base {
21     unsigned num;
22     deferred_access vec[1];
23 } VEC_deferred_access_base;
24 
25 static __inline__ deferred_access *
VEC_deferred_access_base_last(VEC_deferred_access_base * vec_)26 VEC_deferred_access_base_last (VEC_deferred_access_base *vec_)
27 {
28     (void)((vec_ && vec_->num) ? 0 : (vec_assert_fail (), 0));
29     return &vec_->vec[vec_->num - 1];
30 }
31 
32 static __inline__  void
VEC_deferred_access_base_pop(VEC_deferred_access_base * vec_)33 VEC_deferred_access_base_pop (VEC_deferred_access_base *vec_)
34 {
35     (void)((vec_->num) ? 0 : (vec_assert_fail (), 0));
36     --vec_->num;
37 }
38 
39 void __attribute__((noinline))
perform_access_checks(VEC_deferred_access_check_gc * p)40 perform_access_checks (VEC_deferred_access_check_gc* p)
41 {
42     abort ();
43 }
44 
45 typedef struct VEC_deferred_access_gc {
46     VEC_deferred_access_base base;
47 } VEC_deferred_access_gc;
48 
49 static VEC_deferred_access_gc *deferred_access_stack;
50 static unsigned deferred_access_no_check;
51 
52 const struct ggc_root_tab gt_pch_rs_gt_cp_semantics_h[] = {
53     {
54 	&deferred_access_no_check
55     }
56 };
57 
pop_to_parent_deferring_access_checks(void)58 void __attribute__((noinline)) pop_to_parent_deferring_access_checks (void)
59 {
60     if (deferred_access_no_check)
61 	deferred_access_no_check--;
62     else
63     {
64         VEC_deferred_access_check_gc *checks;
65         deferred_access *ptr;
66 	checks = (VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0))->deferred_access_checks;
67         VEC_deferred_access_base_pop(deferred_access_stack ? &deferred_access_stack->base : 0);
68         ptr = VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0);
69         if (ptr->deferring_access_checks_kind == 0)
70 	    perform_access_checks (checks);
71     }
72 }
73 
main()74 int main()
75 {
76     deferred_access_stack = __builtin_malloc (sizeof(VEC_deferred_access_gc) + sizeof(deferred_access) * 8);
77     deferred_access_stack->base.num = 2;
78     deferred_access_stack->base.vec[0].deferring_access_checks_kind = 1;
79     pop_to_parent_deferring_access_checks ();
80     return 0;
81 }
82