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:           Wed May  1 17:42:58 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: decl.c
        src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: make 'offsetof(t, array-member)' a constant expression

The macro 'offsetof(t, m)' already expanded to a constant expression for
scalar members but not for arrays.  This was because the macro expanded
to '(size_t)(((t *)0)->m)', which lint internally represents as
'addr(indir(ptr(0) + offset(m)))', and build_address simplifies
'addr(indir(x))' to 'x' if the types match.  The types only match for
scalar types though, but not for arrays.

When build_address happens, the type information is incomplete,
therefore 'offsetof(t, array)' has to be simplified at a later point.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.638 -r1.639 src/usr.bin/xlint/lint1/tree.c

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