Module Name: src
Committed By: rillig
Date: Sat Apr 2 21:47:04 UTC 2022
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_014.c msg_014.exp
src/usr.bin/xlint/lint1: decl.c err.c
Log Message:
lint: remove unreachable message 'compiler takes alignment of function'
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_014.c \
src/tests/usr.bin/xlint/lint1/msg_014.exp
cvs rdiff -u -r1.264 -r1.265 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/xlint/lint1/err.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/msg_014.c
diff -u src/tests/usr.bin/xlint/lint1/msg_014.c:1.4 src/tests/usr.bin/xlint/lint1/msg_014.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_014.c:1.4 Fri Apr 1 23:16:32 2022
+++ src/tests/usr.bin/xlint/lint1/msg_014.c Sat Apr 2 21:47:04 2022
@@ -1,12 +1,22 @@
-/* $NetBSD: msg_014.c,v 1.4 2022/04/01 23:16:32 rillig Exp $ */
+/* $NetBSD: msg_014.c,v 1.5 2022/04/02 21:47:04 rillig Exp $ */
# 3 "msg_014.c"
// Test for message: compiler takes alignment of function [14]
+/* This message is not used. */
typedef void function(void);
/* expect+1: error: cannot take size/alignment of function type 'function(void) returning void' [144] */
unsigned long alignof_function = __alignof__(function);
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct illegal_bit_field {
+ /* expect+1: warning: illegal bit-field type 'function(void) returning void' [35] */
+ function bit_field:1;
+ /* expect+1: error: function illegal in structure or union [38] */
+ function member;
+};
+
+struct s {
+ /* expect+1: error: array of function is illegal [16] */
+ function member[5];
+};
Index: src/tests/usr.bin/xlint/lint1/msg_014.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_014.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_014.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_014.exp:1.4 Fri Apr 1 23:16:32 2022
+++ src/tests/usr.bin/xlint/lint1/msg_014.exp Sat Apr 2 21:47:04 2022
@@ -1,2 +1,4 @@
-msg_014.c(9): error: cannot take size/alignment of function type 'function(void) returning void' [144]
-msg_014.c(11): error: syntax error ':' [249]
+msg_014.c(10): error: cannot take size/alignment of function type 'function(void) returning void' [144]
+msg_014.c(14): warning: illegal bit-field type 'function(void) returning void' [35]
+msg_014.c(16): error: function illegal in structure or union [38]
+msg_014.c(21): error: array of function is illegal [16]
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.264 src/usr.bin/xlint/lint1/decl.c:1.265
--- src/usr.bin/xlint/lint1/decl.c:1.264 Sat Apr 2 20:12:45 2022
+++ src/usr.bin/xlint/lint1/decl.c Sat Apr 2 21:47:04 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.264 2022/04/02 20:12:45 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.265 2022/04/02 21:47:04 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.264 2022/04/02 20:12:45 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.265 2022/04/02 21:47:04 rillig Exp $");
#endif
#include <sys/param.h>
@@ -888,13 +888,10 @@ alignment_in_bits(const type_t *tp)
while (tp->t_tspec == ARRAY)
tp = tp->t_subt;
- if ((t = tp->t_tspec) == STRUCT || t == UNION) {
+ if (is_struct_or_union(t = tp->t_tspec)) {
a = tp->t_str->sou_align_in_bits;
- } else if (t == FUNC) {
- /* compiler takes alignment of function */
- error(14);
- a = WORST_ALIGN(1) * CHAR_SIZE;
} else {
+ lint_assert(t != FUNC);
if ((a = size_in_bits(t)) == 0) {
a = CHAR_SIZE;
} else if (a > WORST_ALIGN(1) * CHAR_SIZE) {
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.156 src/usr.bin/xlint/lint1/err.c:1.157
--- src/usr.bin/xlint/lint1/err.c:1.156 Sat Apr 2 20:12:46 2022
+++ src/usr.bin/xlint/lint1/err.c Sat Apr 2 21:47:04 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.156 2022/04/02 20:12:46 rillig Exp $ */
+/* $NetBSD: err.c,v 1.157 2022/04/02 21:47:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.156 2022/04/02 20:12:46 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.157 2022/04/02 21:47:04 rillig Exp $");
#endif
#include <sys/types.h>
@@ -68,7 +68,7 @@ const char *const msgs[] = {
"bit-field initializer out of range", /* 11 */
"compiler takes size of function", /* 12 */
"incomplete enum type: %s", /* 13 */
- "compiler takes alignment of function", /* 14 */
+ "", /* 14 */
"function returns illegal type '%s'", /* 15 */
"array of function is illegal", /* 16 */
"null dimension", /* 17 */