Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/usr.bin/xlint/lint1



Module Name:    src
Committed By:   rillig
Date:           Sun Jun 27 18:03:05 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: proof-read the C grammar, remove unnecessary %type

After the fix from the previous commit (a missing assignment to $$ in an
error case), make sure that there are no other bugs of the same kind, by
manually checking that each rule with a %type assigns $$ in each and
every case.  There is one more instance in block_item_list, but that
does not lead to a crash since it affects only a boolean variable, not a
pointer.

It should not be necessary to check for this class of bugs manually, but
neither BSD yacc nor GNU Bison provide any warning option to help with
this scenario.  They should have remarked that the %type for
type_attribute is never used, since that is easy to detect.  They should
have also warned that the rule for block_item_list does not mention $$
at all.

Detecting the bug from the previous commit would probably be too much to
ask since it involves control flow analysis in the C code.  In this
particular case, it would have been necessary to visit each possible
branch from the 'if' statement and ensure that there is a $$ on the
left-hand side of an assignment.

While here, note down several small inconsistencies in the grammar that
should be fixed in follow-up commits.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index