Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: test GCC builtins for overflow in strict bool mode
details: https://anonhg.NetBSD.org/src/rev/b8f06cc52e19
branches: trunk
changeset: 985667:b8f06cc52e19
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Sep 03 22:44:08 2021 +0000
description:
tests/lint: test GCC builtins for overflow in strict bool mode
Seen in inetd.c.
diffstat:
distrib/sets/lists/tests/mi | 4 ++-
tests/usr.bin/xlint/lint1/Makefile | 4 ++-
tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c | 25 ++++++++++++++++++++++
tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp | 2 +
4 files changed, 33 insertions(+), 2 deletions(-)
diffs (71 lines):
diff -r e20606578563 -r b8f06cc52e19 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Sep 03 22:33:17 2021 +0000
+++ b/distrib/sets/lists/tests/mi Fri Sep 03 22:44:08 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1121 2021/08/31 18:59:26 rillig Exp $
+# $NetBSD: mi,v 1.1122 2021/09/03 22:44:08 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6282,6 +6282,8 @@
./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c tests-usr.bin-tests compattestfile,atf
diff -r e20606578563 -r b8f06cc52e19 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Fri Sep 03 22:33:17 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Fri Sep 03 22:44:08 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.108 2021/08/31 18:59:26 rillig Exp $
+# $NetBSD: Makefile,v 1.109 2021/09/03 22:44:09 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 346 # see lint1/err.c
@@ -172,6 +172,8 @@
FILES+= gcc_attribute_var.exp
FILES+= gcc_bit_field_types.c
FILES+= gcc_bit_field_types.exp
+FILES+= gcc_builtin_overflow.c
+FILES+= gcc_builtin_overflow.exp
FILES+= gcc_cast_union.c
FILES+= gcc_cast_union.exp
FILES+= gcc_init_compound_literal.c
diff -r e20606578563 -r b8f06cc52e19 tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c Fri Sep 03 22:44:08 2021 +0000
@@ -0,0 +1,25 @@
+/* $NetBSD: gcc_builtin_overflow.c,v 1.1 2021/09/03 22:44:09 rillig Exp $ */
+# 3 "gcc_builtin_overflow.c"
+
+/*
+ * Some GCC builtin functions return bool, and in lint's strict bool mode,
+ * that makes a difference.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
+ */
+
+/* lint1-extra-flags: -T */
+
+void
+is_overflow(void)
+{
+ int sum;
+
+ /* expect+1: error: controlling expression must be bool, not 'int' [333] */
+ if (__builtin_add_overflow(1, 2, &sum))
+ return;
+
+ /* expect+1: error: controlling expression must be bool, not 'int' [333] */
+ if (__builtin_add_overflow_p(1, 2, 12345))
+ return;
+}
diff -r e20606578563 -r b8f06cc52e19 tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp Fri Sep 03 22:44:08 2021 +0000
@@ -0,0 +1,2 @@
+gcc_builtin_overflow.c(19): error: controlling expression must be bool, not 'int' [333]
+gcc_builtin_overflow.c(23): error: controlling expression must be bool, not 'int' [333]
Home |
Main Index |
Thread Index |
Old Index