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() {
113113
114114 for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
115115 // as a non-const reference
116- f (j) ;
116+ int &m = i ;
117117 }
118118
119119 for (int i = j; i < k; i += l) { // NON_COMPLIANT: The loop counter is passed
120120 // 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;
122128 }
123129
124130 for (int i = j; i < k;
125131 i +=
126132 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
127161 f (k);
128162 }
129163
@@ -135,7 +169,7 @@ int main() {
135169
136170 for (int i = j; i < k;
137171 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
139173 f (l);
140174 }
141175
You can’t perform that action at this time.
0 commit comments