Source-Changes-HG archive

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

[src/trunk]: src tests/lint: demonstrate missing support for __packed __aligned



details:   https://anonhg.NetBSD.org/src/rev/9399b4df6c59
branches:  trunk
changeset: 983087:9399b4df6c59
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 02 20:44:46 2021 +0000

description:
tests/lint: demonstrate missing support for __packed __aligned

diffstat:

 distrib/sets/lists/tests/mi                         |   4 +-
 tests/usr.bin/xlint/lint1/Makefile                  |   4 +-
 tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c   |  44 +++++++++++++++++++++
 tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp |   1 +
 tests/usr.bin/xlint/lint1/t_integration.sh          |   3 +-
 5 files changed, 53 insertions(+), 3 deletions(-)

diffs (106 lines):

diff -r b2e8b077ea45 -r 9399b4df6c59 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun May 02 20:11:43 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun May 02 20:44:46 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1047 2021/04/30 23:49:36 rillig Exp $
+# $NetBSD: mi,v 1.1048 2021/05/02 20:44:46 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6193,6 +6193,8 @@
 ./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_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_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 b2e8b077ea45 -r 9399b4df6c59 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun May 02 20:11:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun May 02 20:44:46 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2021/04/30 23:49:36 rillig Exp $
+# $NetBSD: Makefile,v 1.54 2021/05/02 20:44:46 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   343             # see lint1/err.c
@@ -107,6 +107,8 @@
 FILES+=                feat_stacktrace.exp
 FILES+=                gcc_attribute.c
 FILES+=                gcc_attribute.exp
+FILES+=                gcc_attribute_aligned.c
+FILES+=                gcc_attribute_aligned.exp
 FILES+=                gcc_init_compound_literal.c
 FILES+=                gcc_init_compound_literal.exp
 FILES+=                gcc_typeof_after_statement.c
diff -r b2e8b077ea45 -r 9399b4df6c59 tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c Sun May 02 20:44:46 2021 +0000
@@ -0,0 +1,44 @@
+/*     $NetBSD: gcc_attribute_aligned.c,v 1.1 2021/05/02 20:44:46 rillig Exp $ */
+# 3 "gcc_attribute_aligned.c"
+
+/*
+ * Test size computations on aligned and packed structs.
+ */
+
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+/* from sys/arch/x86/include/cpu_extended_state.h */
+
+union fp_addr {
+       uint64_t fa_64;
+       struct {
+               uint32_t fa_off;
+               uint16_t fa_seg;
+               uint16_t fa_opcode;
+       } fa_32;
+} __attribute__((packed)) __attribute__((aligned(4)));
+
+struct fpacc87 {
+       uint64_t f87_mantissa;
+       uint16_t f87_exp_sign;
+} __attribute__((packed)) __attribute__((aligned(2)));
+
+struct save87 {
+       uint16_t s87_cw __attribute__((aligned(4)));
+       uint16_t s87_sw __attribute__((aligned(4)));
+       uint16_t s87_tw __attribute__((aligned(4)));
+       union fp_addr s87_ip;
+       union fp_addr s87_dp;
+       struct fpacc87 s87_ac[8];
+};
+
+struct {
+       unsigned int sizeof_fp_addr: sizeof(union fp_addr) == 8 ? 1 : -1;
+
+       unsigned int sizeof_fpacc87: sizeof(struct fpacc87) == 10 ? 1 : -1;
+
+       /* expect+1: illegal bit-field size: 255 *//*FIXME*/
+       unsigned int sizeof_save87: sizeof(struct save87) == 108 ? 1 : -1;
+};
diff -r b2e8b077ea45 -r 9399b4df6c59 tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp       Sun May 02 20:44:46 2021 +0000
@@ -0,0 +1,1 @@
+gcc_attribute_aligned.c(43): error: illegal bit-field size: 255 [36]
diff -r b2e8b077ea45 -r 9399b4df6c59 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sun May 02 20:11:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sun May 02 20:44:46 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.45 2021/04/30 23:49:36 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.46 2021/05/02 20:44:46 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -180,6 +180,7 @@
 test_case emit
 
 test_case gcc_attribute
+test_case gcc_attribute_aligned
 test_case gcc_init_compound_literal
 test_case gcc_typeof_after_statement
 



Home | Main Index | Thread Index | Old Index