Module Name: src Committed By: rillig Date: Fri Jan 8 01:40:03 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_204.c msg_204.exp src/usr.bin/xlint/lint1: func.c Log Message: lint: demonstrate wrong message 204 (since 2020-12-31) In func.c 1.39 from 2020-12-31 18:51:28, the check that controlling expressions are indeed scalar was extended from while and for loops to if statements as well. It just seemed to have been an oversight. This revealed a bug in lint, which didn't accept the following valid code snippet from lib/libpthread/pthread.c:634: void _malloc_thread_cleanup(void) __weak; ... if (_malloc_thread_cleanup) _malloc_thread_cleanup(); Testing a function (instead of a function pointer) for truthiness is probably rare since most functions are defined unconditionally. For weak functions it comes in handy though. Clang-Tidy suggests to prefix the function with '&' to silence its warning. Doing that revealed a non-obvious behavior in build_ampersand, which does not add the AMPER node to the expression even though it is clearly mentioned in the code. That is left for further research. Once the original bug is fixed, it probably doesn't matter whether the AMPER is discarded or retained since check_controlling_expression would add it back. There's probably a reason though to sometimes discard the AMPER and sometimes retain it. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_204.c \ src/tests/usr.bin/xlint/lint1/msg_204.exp cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/func.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.