Source-Changes-HG archive

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

[src/trunk]: src tests/lint: add test for bit-field types in GCC mode



details:   https://anonhg.NetBSD.org/src/rev/3319e680aa8f
branches:  trunk
changeset: 378987:3319e680aa8f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 02 21:22:09 2021 +0000

description:
tests/lint: add test for bit-field types in GCC mode

diffstat:

 distrib/sets/lists/tests/mi                       |   4 +-
 tests/usr.bin/xlint/lint1/Makefile                |   4 +-
 tests/usr.bin/xlint/lint1/gcc_bit_field_types.c   |  27 ++++++++++++++++
 tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp |   5 +++
 tests/usr.bin/xlint/lint1/msg_035.c               |   5 ++-
 tests/usr.bin/xlint/lint1/msg_035.exp             |  38 +++++++++++-----------
 tests/usr.bin/xlint/lint1/t_integration.sh        |   3 +-
 7 files changed, 63 insertions(+), 23 deletions(-)

diffs (151 lines):

diff -r bf09ed2e9a92 -r 3319e680aa8f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun May 02 21:05:42 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun May 02 21:22:09 2021 +0000
@@ -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
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun May 02 21:05:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun May 02 21:22:09 2021 +0000
@@ -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
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c   Sun May 02 21:22:09 2021 +0000
@@ -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 */
+};
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp Sun May 02 21:22:09 2021 +0000
@@ -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]
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/msg_035.c
--- a/tests/usr.bin/xlint/lint1/msg_035.c       Sun May 02 21:05:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_035.c       Sun May 02 21:22:09 2021 +0000
@@ -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.
  *
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/msg_035.exp
--- a/tests/usr.bin/xlint/lint1/msg_035.exp     Sun May 02 21:05:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_035.exp     Sun May 02 21:22:09 2021 +0000
@@ -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]
diff -r bf09ed2e9a92 -r 3319e680aa8f tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sun May 02 21:05:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sun May 02 21:22:09 2021 +0000
@@ -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
 



Home | Main Index | Thread Index | Old Index