File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,7 +193,9 @@ void misra_15_6() {
193193}
194194
195195void misra_15_7 () {
196- if (x != 0 ){} // 15.7
196+ if (x != 0 ){} // no-warning
197+ if (x != 0 ){} else if (x == 1 ){} // 15.7
198+ if (x != 0 ){} else if (x == 1 ){}else {;} // no-warning
197199}
198200
199201void misra_16_2 () {
Original file line number Diff line number Diff line change @@ -773,11 +773,13 @@ def misra_15_6(rawTokens):
773773
774774def misra_15_7 (data ):
775775 for token in data .tokenlist :
776- if not simpleMatch (token , 'if ( ' ):
776+ if not simpleMatch (token , '} ' ):
777777 continue
778- if not simpleMatch (token .next .link , ') {' ):
778+ if not token .scope .type == 'If' :
779+ continue
780+ if not token .scope .nestedIn .type == 'Else' :
779781 continue
780- if not simpleMatch ( token .next .link . next . link , '} else') :
782+ if not token .next .str == ' else' :
781783 reportError (token , 15 , 7 )
782784
783785# TODO add 16.1 rule
You can’t perform that action at this time.
0 commit comments