Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: remove unreachable message 'compil...



details:   https://anonhg.NetBSD.org/src/rev/d186724bbd64
branches:  trunk
changeset: 364650:d186724bbd64
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 02 21:47:04 2022 +0000

description:
lint: remove unreachable message 'compiler takes alignment of function'

diffstat:

 tests/usr.bin/xlint/lint1/msg_014.c   |  16 +++++++++++++---
 tests/usr.bin/xlint/lint1/msg_014.exp |   6 ++++--
 usr.bin/xlint/lint1/decl.c            |  11 ++++-------
 usr.bin/xlint/lint1/err.c             |   6 +++---
 4 files changed, 24 insertions(+), 15 deletions(-)

diffs (100 lines):

diff -r 609a92b204bc -r d186724bbd64 tests/usr.bin/xlint/lint1/msg_014.c
--- a/tests/usr.bin/xlint/lint1/msg_014.c       Sat Apr 02 20:12:45 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_014.c       Sat Apr 02 21:47:04 2022 +0000
@@ -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];
+};
diff -r 609a92b204bc -r d186724bbd64 tests/usr.bin/xlint/lint1/msg_014.exp
--- a/tests/usr.bin/xlint/lint1/msg_014.exp     Sat Apr 02 20:12:45 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_014.exp     Sat Apr 02 21:47:04 2022 +0000
@@ -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]
diff -r 609a92b204bc -r d186724bbd64 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Apr 02 20:12:45 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Apr 02 21:47:04 2022 +0000
@@ -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 @@
        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) {
diff -r 609a92b204bc -r d186724bbd64 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sat Apr 02 20:12:45 2022 +0000
+++ b/usr.bin/xlint/lint1/err.c Sat Apr 02 21:47:04 2022 +0000
@@ -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 @@
        "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 */



Home | Main Index | Thread Index | Old Index