Thu Jul 15 21:56:51 2021 UTC ()
lint: fix internal error for sizeof(typeof)


(rillig)
diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/decl.c
diff -r1.200 -r1.201 src/usr.bin/xlint/lint1/decl.c

cvs diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/decl.c 2021/07/15 21:34:11 1.7
+++ src/tests/usr.bin/xlint/lint1/decl.c 2021/07/15 21:56:51 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.7 2021/07/15 21:34:11 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.8 2021/07/15 21:56:51 rillig Exp $ */
2# 3 "decl.c" 2# 3 "decl.c"
3 3
4/* 4/*
5 * Tests for declarations, especially the distinction between the 5 * Tests for declarations, especially the distinction between the
6 * declaration-specifiers and the declarators. 6 * declaration-specifiers and the declarators.
7 */ 7 */
8 8
9/* 9/*
10 * Even though 'const' comes after 'char' and is therefore quite close to the 10 * Even though 'const' comes after 'char' and is therefore quite close to the
11 * first identifier, it applies to both identifiers. 11 * first identifier, it applies to both identifiers.
12 */ 12 */
13void 13void
14specifier_qualifier(void) 14specifier_qualifier(void)
@@ -121,17 +121,43 @@ unused(void) @@ -121,17 +121,43 @@ unused(void)
121 */ 121 */
122/* LINTED */ 122/* LINTED */
123static void 123static void
124unused_linted(void) 124unused_linted(void)
125{ 125{
126} 126}
127 127
128/* covers 'type_qualifier_list: type_qualifier_list type_qualifier' */ 128/* covers 'type_qualifier_list: type_qualifier_list type_qualifier' */
129int *const volatile cover_type_qualifier_list; 129int *const volatile cover_type_qualifier_list;
130 130
131unsigned long cover_abstract_declaration_declmods = sizeof(const); 131unsigned long cover_abstract_declaration_declmods = sizeof(const);
132unsigned long cover_abstract_declaration_declmods_abstract_declarator = 132unsigned long cover_abstract_declaration_declmods_abstract_declarator =
133 sizeof(const *); 133 sizeof(const *);
134// FIXME: 134
135// lint: internal error in decl.c:833 near decl.c:135: end_type(unsigned long) 135unsigned long cover_abstract_declarator_typeof =
136//unsigned long cover_abstract_declarator_typeof = 136 sizeof(const typeof(cover_abstract_declaration_declmods));
137// sizeof(const typeof(cover_abstract_declaration_declmods)); 137
 138_Bool bool;
 139char plain_char;
 140signed char signed_char;
 141unsigned char unsigned_char;
 142short signed_short;
 143unsigned short unsigned_short;
 144int signed_int;
 145unsigned int unsigned_int;
 146long signed_long;
 147unsigned long unsigned_long;
 148
 149/*
 150 * Before decl.c 1.201 from 2021-07-15, lint crashed with an internal error
 151 * in end_type.
 152 */
 153unsigned long sizes =
 154 sizeof(const typeof(bool)) +
 155 sizeof(const typeof(plain_char)) +
 156 sizeof(const typeof(signed_char)) +
 157 sizeof(const typeof(unsigned_char)) +
 158 sizeof(const typeof(signed_short)) +
 159 sizeof(const typeof(unsigned_short)) +
 160 sizeof(const typeof(signed_int)) +
 161 sizeof(const typeof(unsigned_int)) +
 162 sizeof(const typeof(signed_long)) +
 163 sizeof(const typeof(unsigned_long));

cvs diff -r1.200 -r1.201 src/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/decl.c 2021/07/15 07:58:05 1.200
+++ src/usr.bin/xlint/lint1/decl.c 2021/07/15 21:56:51 1.201
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.200 2021/07/15 07:58:05 rin Exp $ */ 1/* $NetBSD: decl.c,v 1.201 2021/07/15 21:56:51 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: decl.c,v 1.200 2021/07/15 07:58:05 rin Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.201 2021/07/15 21:56:51 rillig Exp $");
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50 50
51const char *unnamed = "<unnamed>"; 51const char *unnamed = "<unnamed>";
52 52
53/* shared type structures for arithmetic types and void */ 53/* shared type structures for arithmetic types and void */
54static type_t *typetab; 54static type_t *typetab;
@@ -820,26 +820,28 @@ end_type(void) @@ -820,26 +820,28 @@ end_type(void)
820 if (l == LONG) { 820 if (l == LONG) {
821 l = NOTSPEC; 821 l = NOTSPEC;
822 t = LCOMPLEX; 822 t = LCOMPLEX;
823 if (tflag) 823 if (tflag)
824 /* 'long double' is illegal in ... */ 824 /* 'long double' is illegal in ... */
825 warning(266); 825 warning(266);
826 } 826 }
827 break; 827 break;
828 case VOID: 828 case VOID:
829 case FCOMPLEX: 829 case FCOMPLEX:
830 case LCOMPLEX: 830 case LCOMPLEX:
831 break; 831 break;
832 default: 832 default:
 833 if (is_integer(t))
 834 break;
833 INTERNAL_ERROR("end_type(%s)", tspec_name(t)); 835 INTERNAL_ERROR("end_type(%s)", tspec_name(t));
834 } 836 }
835 if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) { 837 if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) {
836 dcs->d_terr = true; 838 dcs->d_terr = true;
837 l = s = NOTSPEC; 839 l = s = NOTSPEC;
838 } 840 }
839 if (l != NOTSPEC) 841 if (l != NOTSPEC)
840 t = l; 842 t = l;
841 dcs->d_type = gettyp(merge_type_specifiers(t, s)); 843 dcs->d_type = gettyp(merge_type_specifiers(t, s));
842 } 844 }
843 845
844 if (dcs->d_mscl) { 846 if (dcs->d_mscl) {
845 /* only one storage class allowed */ 847 /* only one storage class allowed */