about summary refs log tree commit diff stats
path: root/html/061abandon_checks.cc.html
blob: 9f91f90eebf1ac98165e5673bb702c1dddbc0dc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 061abandon_checks.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v1">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 1.05em; }
.Comment { color: #9090ff; }
.Delimiter { color: #a04060; }
.Special { color: #ff6060; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Delimiter">:(scenarios transform)</span>  <span class="Comment">// many of the tests below are *extremely* unsafe</span>
<span class="Delimiter">:(scenario abandon_in_same_recipe_as_new)</span>
recipe test [
  x:address:number<span class="Special"> &lt;- </span>new number:type
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_in_separate_recipe_from_new)</span>
recipe test [
  x:address:number<span class="Special"> &lt;- </span>test-new
  test-abandon x
]
recipe test-new <span class="Delimiter">-&gt;</span> result:address:number [
  result<span class="Special"> &lt;- </span>new number:type
]
recipe test-abandon x:address:number [
  load-ingredients
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario define_after_abandon_in_same_recipe_as_new)</span>
recipe test [
  x:address:number<span class="Special"> &lt;- </span>new number:type
  abandon x
  x<span class="Special"> &lt;- </span>new number:type
  reply x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario define_after_abandon_in_separate_recipe_from_new)</span>
recipe test [
  x:address:number<span class="Special"> &lt;- </span>test-new
  test-abandon x
  x<span class="Special"> &lt;- </span>test-new
  reply x
]
recipe test-new <span class="Delimiter">-&gt;</span> result:address:number [
  result<span class="Special"> &lt;- </span>new number:type
]
recipe test-abandon x:address:number [
  load-ingredients
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable)</span>
recipe test [
  <span class="Delimiter">{</span>
    x:address:number<span class="Special"> &lt;- </span>new number:type
    abandon x
    loop
  <span class="Delimiter">}</span>
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_2)</span>
recipe test [
  <span class="Delimiter">{</span>
    x:address:number<span class="Special"> &lt;- </span>test-new
    test-abandon x
    loop
  <span class="Delimiter">}</span>
]
recipe test-new <span class="Delimiter">-&gt;</span> result:address:number [
  result<span class="Special"> &lt;- </span>new number:type
]
recipe test-abandon x:address:number [
  load-ingredients
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_3)</span>
recipe test [
  <span class="Delimiter">{</span>
    x:address:number<span class="Special"> &lt;- </span>test-new
    test-abandon x
    x:address:number<span class="Special"> &lt;- </span>test-new  <span class="Comment"># modify x to a new value</span>
    y:address:number<span class="Special"> &lt;- </span>copy x  <span class="Comment"># use x after reinitialization</span>
    loop
  <span class="Delimiter">}</span>
]
recipe test-new <span class="Delimiter">-&gt;</span> result:address:number [
  result<span class="Special"> &lt;- </span>new number:type
]
recipe test-abandon x:address:number [
  load-ingredients
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_4)</span>
container test-list [
  value:number
  next:address:test-list
]
recipe test-cleanup x:address:test-list [
  load-ingredients
  <span class="Delimiter">{</span>
    next:address:test-list<span class="Special"> &lt;- </span>test-next x
    test-abandon x
    x<span class="Special"> &lt;- </span>copy next
    loop
  <span class="Delimiter">}</span>
]
recipe test-next x:address:test-list <span class="Delimiter">-&gt;</span> result:address:test-list/contained-in:x [
  load-ingredients
  result<span class="Special"> &lt;- </span>get *x<span class="Delimiter">,</span> next:offset
]
recipe test-abandon x:address:test-list [
  load-ingredients
  abandon x
]
<span class="Comment"># no warnings</span>

<span class="Delimiter">:(scenario abandon_non_unique_address_after_define)</span>
recipe test [
  x:address:number<span class="Special"> &lt;- </span>new number:type
  y:address:number<span class="Special"> &lt;- </span>copy x
  abandon x
  y:address:number<span class="Special"> &lt;- </span>new number:type  <span class="Comment"># overwrite alias</span>
  z:address:number<span class="Special"> &lt;- </span>copy y
]
<span class="Comment"># no warnings</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->