Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: demonstrate wrong warning for __builtin_alloca
details: https://anonhg.NetBSD.org/src/rev/6ce6dbc6cc3a
branches: trunk
changeset: 1026780:6ce6dbc6cc3a
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Dec 06 23:20:26 2021 +0000
description:
tests/lint: demonstrate wrong warning for __builtin_alloca
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 +++-
tests/usr.bin/xlint/lint1/gcc_builtin_alloca.c | 21 +++++++++++++++++++++
tests/usr.bin/xlint/lint1/gcc_builtin_alloca.exp | 2 ++
4 files changed, 29 insertions(+), 2 deletions(-)
diffs (67 lines):
diff -r 1150d24b0d39 -r 6ce6dbc6cc3a distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Dec 06 23:07:49 2021 +0000
+++ b/distrib/sets/lists/tests/mi Mon Dec 06 23:20:26 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1174 2021/12/05 15:20:13 rillig Exp $
+# $NetBSD: mi,v 1.1175 2021/12/06 23:20:26 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6468,6 +6468,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_alloca.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.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
diff -r 1150d24b0d39 -r 6ce6dbc6cc3a tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Mon Dec 06 23:07:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Mon Dec 06 23:20:26 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.114 2021/10/30 22:04:42 rillig Exp $
+# $NetBSD: Makefile,v 1.115 2021/12/06 23:20:26 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 348 # see lint1/err.c
@@ -174,6 +174,8 @@
FILES+= gcc_attribute_var.exp
FILES+= gcc_bit_field_types.c
FILES+= gcc_bit_field_types.exp
+FILES+= gcc_builtin_alloca.c
+FILES+= gcc_builtin_alloca.exp
FILES+= gcc_builtin_overflow.c
FILES+= gcc_builtin_overflow.exp
FILES+= gcc_cast_union.c
diff -r 1150d24b0d39 -r 6ce6dbc6cc3a tests/usr.bin/xlint/lint1/gcc_builtin_alloca.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.c Mon Dec 06 23:20:26 2021 +0000
@@ -0,0 +1,21 @@
+/* $NetBSD: gcc_builtin_alloca.c,v 1.1 2021/12/06 23:20:26 rillig Exp $ */
+# 3 "gcc_builtin_alloca.c"
+
+/*
+ * Test for the GCC builtin functions __builtin_alloca*, which unlike most
+ * other builtin functions return a pointer instead of int.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ */
+
+void
+example(void)
+{
+ /* expect+1: warning: illegal combination of pointer (pointer to char) and integer (int) [183] */
+ char *ptr = __builtin_alloca(8);
+ ptr[4] = '4';
+
+ /* expect+1: warning: illegal combination of pointer (pointer to char) and integer (int) [183] */
+ char *aligned_ptr = __builtin_alloca_with_align(8, 64);
+ aligned_ptr[0] = '\0';
+}
diff -r 1150d24b0d39 -r 6ce6dbc6cc3a tests/usr.bin/xlint/lint1/gcc_builtin_alloca.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.exp Mon Dec 06 23:20:26 2021 +0000
@@ -0,0 +1,2 @@
+gcc_builtin_alloca.c(15): warning: illegal combination of pointer (pointer to char) and integer (int) [183]
+gcc_builtin_alloca.c(19): warning: illegal combination of pointer (pointer to char) and integer (int) [183]
Home |
Main Index |
Thread Index |
Old Index