Module Name: src Committed By: rillig Date: Sat Aug 27 21:59:41 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: gcc_attribute_aligned.c Log Message: tests/lint: add another test for aligned struct member In the kernel, several structs have this attribute, and running lint on them runs into a compile-time assertion. Typical error messages are: * error: illegal bit-field size: 255 [36] * error: integral constant expression expected [55] To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.3 src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.4 --- src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c:1.3 Fri Jun 17 18:54:53 2022 +++ src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c Sat Aug 27 21:59:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gcc_attribute_aligned.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ +/* $NetBSD: gcc_attribute_aligned.c,v 1.4 2022/08/27 21:59:41 rillig Exp $ */ # 3 "gcc_attribute_aligned.c" /* @@ -43,3 +43,17 @@ struct { /* expect+1: error: illegal bit-field size: 255 [36] */ unsigned int sizeof_save87: sizeof(struct save87) == 108 ? 1 : -1; }; + + +void +aligned_struct_member(void) +{ + struct aligned { + int first; + int second __attribute__((__aligned__(16))); + }; + + /* TODO: should be -20 instead of -8. */ + /* expect+1: error: negative array dimension (-8) [20] */ + typedef int ctassert[-(int)sizeof(struct aligned)]; +}