Source-Changes archive

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

CVS commit: src



Module Name:    src
Committed By:   rillig
Date:           Thu Jul  8 18:50:57 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
        src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: demonstrate bug in handling enum declarations (since today)

Since cgram.y 1.270 from today (a "cleanup" commit), the enum constants
were only registered in the symbol table, but they were not added to the
enum type (en_first_enumerator).  That information is used for
validating switch statements on enum types.

The actual bug is an off-by-one error in the grammar, in the grammar
rule 'enum_declaration'.  Yacc does not notice this obvious error.
Bison does, but it is not involved in building lint.

In the grammar rule 'enum_declaration', the intended $3 contains the
first enumeration constant of the type, while $2, which yacc interprets
as a symbol, contains a null pointer, at least on x86_64.

The existing tests did not cover this scenario, so the bug went
unnoticed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_206.c \
    src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.271 -r1.272 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