File tree Expand file tree Collapse file tree 1 file changed +37
-3
lines changed
cpp/misra/test/rules/RULE-9-5-1 Expand file tree Collapse file tree 1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -113,17 +113,51 @@ int main() {
113
113
114
114
for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
115
115
// as a non-const reference
116
- f (j) ;
116
+ int &m = i ;
117
117
}
118
118
119
119
for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
120
120
// as a non-const pointer
121
- g (&j);
121
+ int *m = &i;
122
+ }
123
+
124
+ for (int i = j; i < k;
125
+ i +=
126
+ l) { // NON_COMPLIANT: The loop bound is passed as a non-const reference
127
+ int &m = k;
122
128
}
123
129
124
130
for (int i = j; i < k;
125
131
i +=
126
132
l) { // NON_COMPLIANT: The loop bound is passed as a non-const pointer
133
+ int *m = &k;
134
+ }
135
+
136
+ for (int i = j; i < k;
137
+ i +=
138
+ l) { // NON_COMPLIANT: The loop step is passed as a non-const reference
139
+ int &m = l;
140
+ }
141
+
142
+ for (int i = j; i < k;
143
+ i +=
144
+ l) { // NON_COMPLIANT: The loop step is passed as a non-const pointer
145
+ int *m = &l;
146
+ }
147
+
148
+ for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
149
+ // as a non-const reference
150
+ f (i);
151
+ }
152
+
153
+ for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
154
+ // as a non-const pointer
155
+ g (&i);
156
+ }
157
+
158
+ for (int i = j; i < k;
159
+ i +=
160
+ l) { // NON_COMPLIANT: The loop bound is passed as a non-const reference
127
161
f (k);
128
162
}
129
163
@@ -135,7 +169,7 @@ int main() {
135
169
136
170
for (int i = j; i < k;
137
171
i +=
138
- l) { // NON_COMPLIANT: The loop step is passed as a non-const pointer
172
+ l) { // NON_COMPLIANT: The loop step is passed as a non-const reference
139
173
f (l);
140
174
}
141
175
You can’t perform that action at this time.
0 commit comments