Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: demonstrate that GCC b...



details:   https://anonhg.NetBSD.org/src/rev/ee5dca15aa96
branches:  trunk
changeset: 985497:ee5dca15aa96
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 28 16:21:24 2021 +0000

description:
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.

diffstat:

 tests/usr.bin/xlint/lint1/emit.c      |  22 +++++++++++++++++++---
 tests/usr.bin/xlint/lint1/emit.exp-ln |   7 +++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diffs (58 lines):

diff -r 16e545cbe318 -r ee5dca15aa96 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Sat Aug 28 16:00:52 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Sat Aug 28 16:21:24 2021 +0000
@@ -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 @@
        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);
+}
diff -r 16e545cbe318 -r ee5dca15aa96 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Sat Aug 28 16:00:52 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Sat Aug 28 16:21:24 2021 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index