Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: add very basic tests for GCC __attribute__
details: https://anonhg.NetBSD.org/src/rev/eff99675e404
branches: trunk
changeset: 983047:eff99675e404
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Apr 30 23:49:36 2021 +0000
description:
tests/lint: add very basic tests for GCC __attribute__
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 +++-
tests/usr.bin/xlint/lint1/gcc_attribute.c | 28 ++++++++++++++++++++++++++++
tests/usr.bin/xlint/lint1/gcc_attribute.exp | 2 ++
tests/usr.bin/xlint/lint1/t_integration.sh | 3 ++-
5 files changed, 38 insertions(+), 3 deletions(-)
diffs (91 lines):
diff -r 6e2dd536b4ad -r eff99675e404 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Apr 30 22:48:37 2021 +0000
+++ b/distrib/sets/lists/tests/mi Fri Apr 30 23:49:36 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1046 2021/04/27 16:20:06 rillig Exp $
+# $NetBSD: mi,v 1.1047 2021/04/30 23:49:36 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6191,6 +6191,8 @@
./usr/tests/usr.bin/xlint/lint1/emit.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c tests-usr.bin-tests compattestfile,atf
diff -r 6e2dd536b4ad -r eff99675e404 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Fri Apr 30 22:48:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Fri Apr 30 23:49:36 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.52 2021/04/22 22:43:26 rillig Exp $
+# $NetBSD: Makefile,v 1.53 2021/04/30 23:49:36 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 343 # see lint1/err.c
@@ -105,6 +105,8 @@
FILES+= emit.ln
FILES+= feat_stacktrace.c
FILES+= feat_stacktrace.exp
+FILES+= gcc_attribute.c
+FILES+= gcc_attribute.exp
FILES+= gcc_init_compound_literal.c
FILES+= gcc_init_compound_literal.exp
FILES+= gcc_typeof_after_statement.c
diff -r 6e2dd536b4ad -r eff99675e404 tests/usr.bin/xlint/lint1/gcc_attribute.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.c Fri Apr 30 23:49:36 2021 +0000
@@ -0,0 +1,28 @@
+/* $NetBSD: gcc_attribute.c,v 1.1 2021/04/30 23:49:36 rillig Exp $ */
+# 3 "gcc_attribute.c"
+
+/*
+ * Tests for the various attributes for functions, types, statements that are
+ * provided by GCC.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html
+ * https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html
+ */
+
+void __attribute__((noinline))
+do_not_inline(void)
+{
+}
+
+/* expect+1: syntax error 'nonnull' */
+void __attribute__((nonnull(1, 2)))
+my_memcpy(void *dest, const void *src, unsigned long len);
+
+/* expect+1: syntax error 'unknown_attribute' */
+void __attribute__((unknown_attribute))
+function_with_unknown_attribute(void);
diff -r 6e2dd536b4ad -r eff99675e404 tests/usr.bin/xlint/lint1/gcc_attribute.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.exp Fri Apr 30 23:49:36 2021 +0000
@@ -0,0 +1,2 @@
+gcc_attribute.c(23): error: syntax error 'nonnull' [249]
+gcc_attribute.c(27): error: syntax error 'unknown_attribute' [249]
diff -r 6e2dd536b4ad -r eff99675e404 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Fri Apr 30 22:48:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Fri Apr 30 23:49:36 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.44 2021/04/22 22:43:26 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.45 2021/04/30 23:49:36 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -179,6 +179,7 @@
test_case emit
+test_case gcc_attribute
test_case gcc_init_compound_literal
test_case gcc_typeof_after_statement
Home |
Main Index |
Thread Index |
Old Index