Module Name: src
Committed By: rillig
Date: Sun May 2 21:22:09 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile msg_035.c msg_035.exp
t_integration.sh
Added Files:
src/tests/usr.bin/xlint/lint1: gcc_bit_field_types.c
gcc_bit_field_types.exp
Log Message:
tests/lint: add test for bit-field types in GCC mode
To generate a diff of this commit:
cvs rdiff -u -r1.1048 -r1.1049 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.54 -r1.55 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c \
src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_035.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_035.exp
cvs rdiff -u -r1.46 -r1.47 src/tests/usr.bin/xlint/lint1/t_integration.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1048 src/distrib/sets/lists/tests/mi:1.1049
--- src/distrib/sets/lists/tests/mi:1.1048 Sun May 2 20:44:46 2021
+++ src/distrib/sets/lists/tests/mi Sun May 2 21:22:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1048 2021/05/02 20:44:46 rillig Exp $
+# $NetBSD: mi,v 1.1049 2021/05/02 21:22:09 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6195,6 +6195,8 @@
./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.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_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
Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.54 src/tests/usr.bin/xlint/lint1/Makefile:1.55
--- src/tests/usr.bin/xlint/lint1/Makefile:1.54 Sun May 2 20:44:46 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile Sun May 2 21:22:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.54 2021/05/02 20:44:46 rillig Exp $
+# $NetBSD: Makefile,v 1.55 2021/05/02 21:22:09 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 343 # see lint1/err.c
@@ -109,6 +109,8 @@ FILES+= gcc_attribute.c
FILES+= gcc_attribute.exp
FILES+= gcc_attribute_aligned.c
FILES+= gcc_attribute_aligned.exp
+FILES+= gcc_bit_field_types.c
+FILES+= gcc_bit_field_types.exp
FILES+= gcc_init_compound_literal.c
FILES+= gcc_init_compound_literal.exp
FILES+= gcc_typeof_after_statement.c
Index: src/tests/usr.bin/xlint/lint1/msg_035.c
diff -u src/tests/usr.bin/xlint/lint1/msg_035.c:1.8 src/tests/usr.bin/xlint/lint1/msg_035.c:1.9
--- src/tests/usr.bin/xlint/lint1/msg_035.c:1.8 Mon Apr 5 01:35:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_035.c Sun May 2 21:22:09 2021
@@ -1,8 +1,11 @@
-/* $NetBSD: msg_035.c,v 1.8 2021/04/05 01:35:34 rillig Exp $ */
+/* $NetBSD: msg_035.c,v 1.9 2021/05/02 21:22:09 rillig Exp $ */
# 3 "msg_035.c"
// Test for message: illegal bit-field type '%s' [35]
+/* Omit -g, see gcc_bit_field_types.c. */
+/* lint1-flags: -Sw */
+
/*
* In traditional C, only unsigned int is a portable bit-field type.
*
Index: src/tests/usr.bin/xlint/lint1/msg_035.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_035.exp:1.10 src/tests/usr.bin/xlint/lint1/msg_035.exp:1.11
--- src/tests/usr.bin/xlint/lint1/msg_035.exp:1.10 Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_035.exp Sun May 2 21:22:09 2021
@@ -1,19 +1,19 @@
-msg_035.c(41): warning: illegal bit-field type 'long' [35]
-msg_035.c(42): warning: illegal bit-field type 'unsigned long' [35]
-msg_035.c(43): warning: illegal bit-field type 'long long' [35]
-msg_035.c(44): warning: illegal bit-field type 'unsigned long long' [35]
-msg_035.c(47): warning: illegal bit-field type 'float' [35]
-msg_035.c(48): warning: illegal bit-field type 'double' [35]
-msg_035.c(49): warning: illegal bit-field type 'long double' [35]
-msg_035.c(50): error: void type for 'void_flag' [19]
-msg_035.c(50): error: zero size bit-field [37]
-msg_035.c(51): warning: illegal bit-field type 'struct typedef example_struct' [35]
-msg_035.c(52): warning: illegal bit-field type 'union typedef example_union' [35]
-msg_035.c(54): warning: illegal bit-field type 'pointer to void' [35]
-msg_035.c(55): warning: illegal bit-field type 'array[4] of unsigned int' [35]
-msg_035.c(56): warning: illegal bit-field type 'function(int, pointer to const char) returning void' [35]
-msg_035.c(57): error: invalid type for _Complex [308]
-msg_035.c(57): warning: illegal bit-field type 'double _Complex' [35]
-msg_035.c(58): warning: illegal bit-field type 'float _Complex' [35]
-msg_035.c(59): warning: illegal bit-field type 'double _Complex' [35]
-msg_035.c(60): warning: illegal bit-field type 'long double _Complex' [35]
+msg_035.c(44): warning: illegal bit-field type 'long' [35]
+msg_035.c(45): warning: illegal bit-field type 'unsigned long' [35]
+msg_035.c(46): warning: illegal bit-field type 'long long' [35]
+msg_035.c(47): warning: illegal bit-field type 'unsigned long long' [35]
+msg_035.c(50): warning: illegal bit-field type 'float' [35]
+msg_035.c(51): warning: illegal bit-field type 'double' [35]
+msg_035.c(52): warning: illegal bit-field type 'long double' [35]
+msg_035.c(53): error: void type for 'void_flag' [19]
+msg_035.c(53): error: zero size bit-field [37]
+msg_035.c(54): warning: illegal bit-field type 'struct typedef example_struct' [35]
+msg_035.c(55): warning: illegal bit-field type 'union typedef example_union' [35]
+msg_035.c(57): warning: illegal bit-field type 'pointer to void' [35]
+msg_035.c(58): warning: illegal bit-field type 'array[4] of unsigned int' [35]
+msg_035.c(59): warning: illegal bit-field type 'function(int, pointer to const char) returning void' [35]
+msg_035.c(60): error: invalid type for _Complex [308]
+msg_035.c(60): warning: illegal bit-field type 'double _Complex' [35]
+msg_035.c(61): warning: illegal bit-field type 'float _Complex' [35]
+msg_035.c(62): warning: illegal bit-field type 'double _Complex' [35]
+msg_035.c(63): warning: illegal bit-field type 'long double _Complex' [35]
Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.46 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.47
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.46 Sun May 2 20:44:46 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh Sun May 2 21:22:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.46 2021/05/02 20:44:46 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.47 2021/05/02 21:22:09 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -181,6 +181,7 @@ test_case emit
test_case gcc_attribute
test_case gcc_attribute_aligned
+test_case gcc_bit_field_types
test_case gcc_init_compound_literal
test_case gcc_typeof_after_statement
Added files:
Index: src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.1
--- /dev/null Sun May 2 21:22:10 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c Sun May 2 21:22:09 2021
@@ -0,0 +1,27 @@
+/* $NetBSD: gcc_bit_field_types.c,v 1.1 2021/05/02 21:22:09 rillig Exp $ */
+# 3 "gcc_bit_field_types.c"
+
+/*
+ * https://gcc.gnu.org/onlinedocs/gcc/Structures-unions-enumerations-and-bit-fields-implementation.html
+ *
+ * "Other integer types, such as long int, and enumerated types are permitted
+ * even in strictly conforming mode."
+ *
+ * See msg_035.c.
+ */
+
+// Test for message: illegal bit-field type '%s' [35]
+
+/* Omit -g, see gcc_bit_field_types.c. */
+/* lint1-flags: -Sw */
+
+/* Try all types from tspec_t. */
+struct example {
+ int int_flag: 1;
+ unsigned int unsigned_int_flag: 1;
+ long long_flag: 1; /* expect: 35 *//*FIXME*/
+ unsigned long unsigned_long_flag: 1; /* expect: 35 *//*FIXME*/
+ long long long_long_flag: 1; /* expect: 35 *//*FIXME*/
+ unsigned long long unsigned_long_long_flag: 1; /* expect: 35 *//*FIXME*/
+ double double_flag: 1; /* expect: 35 */
+};
Index: src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp:1.1
--- /dev/null Sun May 2 21:22:10 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp Sun May 2 21:22:09 2021
@@ -0,0 +1,5 @@
+gcc_bit_field_types.c(22): warning: illegal bit-field type 'long' [35]
+gcc_bit_field_types.c(23): warning: illegal bit-field type 'unsigned long' [35]
+gcc_bit_field_types.c(24): warning: illegal bit-field type 'long long' [35]
+gcc_bit_field_types.c(25): warning: illegal bit-field type 'unsigned long long' [35]
+gcc_bit_field_types.c(26): warning: illegal bit-field type 'double' [35]