Module Name: src Committed By: rillig Date: Sat Aug 28 16:21:25 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: emit.c emit.exp-ln Log Message: tests/lint: demonstrate that GCC builtins are emitted by default They will be skipped in a follow-up commit, but to see the effects of that, they first need to be emitted. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/emit.c \ src/tests/usr.bin/xlint/lint1/emit.exp-ln Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/emit.c diff -u src/tests/usr.bin/xlint/lint1/emit.c:1.2 src/tests/usr.bin/xlint/lint1/emit.c:1.3 --- src/tests/usr.bin/xlint/lint1/emit.c:1.2 Sun Aug 8 11:07:19 2021 +++ src/tests/usr.bin/xlint/lint1/emit.c Sat Aug 28 16:21:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.2 2021/08/08 11:07:19 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.3 2021/08/28 16:21:24 rillig Exp $ */ # 3 "emit.c" /* @@ -7,8 +7,8 @@ * consistently across different translation units. */ -// omit the option '-g' to avoid having the GCC builtins in the .ln file. -/* lint1-flags: -Sw */ + + /* * Define some derived types. @@ -163,3 +163,19 @@ cover_outqchar(void) my_printf("%s", "%%"); my_printf("%s", "%\a %\b %\f %\n %\r %\t %\v %\177"); } + +/* + * Calls to GCC builtin functions should not be emitted since GCC already + * guarantees a consistent definition of these function and checks the + * arguments, so there is nothing left to do for lint. + */ +void +call_gcc_builtins(int x, long *ptr) +{ + long value; + + __builtin_expect(x > 0, 1); + __builtin_bswap32(0x12345678); + + __atomic_load(ptr, &value, 0); +} Index: src/tests/usr.bin/xlint/lint1/emit.exp-ln diff -u src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.2 src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.3 --- src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.2 Sun Aug 8 11:07:19 2021 +++ src/tests/usr.bin/xlint/lint1/emit.exp-ln Sat Aug 28 16:21:24 2021 @@ -1,3 +1,6 @@ +1d-1.1e15__builtin_isinfF1lDI +2d-1.2e15__builtin_isnanF1lDI +3d-1.3e18__builtin_copysignF2lDlDI 0semit.c Semit.c 47d0.47e12extern__BoolB @@ -56,3 +59,7 @@ Semit.c 163c0.163s2"%%"i9my_printff2PcCPCV 164c0.164s2"%\a%\b%\f%\n%\r%\t%\v%\177"i9my_printff2PcCPCV 159d0.159d14cover_outqcharF0V +177c0.177p2i16__builtin_expectf2III +178c0.178p1i17__builtin_bswap32f1II +180c0.180z3i13__atomic_loadf3PLPLII +173d0.173d17call_gcc_builtinsF2IPLV