| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: decl.c,v 1.98 2021/01/02 03:49:25 rillig Exp $ */ | | 1 | /* $NetBSD: decl.c,v 1.99 2021/01/02 16:33:39 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.98 2021/01/02 03:49:25 rillig Exp $"); | | 41 | __RCSID("$NetBSD: decl.c,v 1.99 2021/01/02 16:33:39 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 | |
51 | const char *unnamed = "<unnamed>"; | | 51 | const char *unnamed = "<unnamed>"; |
52 | | | 52 | |
53 | /* shared type structures for arithmtic types and void */ | | 53 | /* shared type structures for arithmtic types and void */ |
54 | static type_t *typetab; | | 54 | static type_t *typetab; |
| @@ -1108,27 +1108,27 @@ declarator_1_struct_union(sym_t *dsym) | | | @@ -1108,27 +1108,27 @@ declarator_1_struct_union(sym_t *dsym) |
1108 | if (sflag) { | | 1108 | if (sflag) { |
1109 | /* bit-field type '%s' invalid ... */ | | 1109 | /* bit-field type '%s' invalid ... */ |
1110 | warning(273, type_name(tp)); | | 1110 | warning(273, type_name(tp)); |
1111 | } else if (pflag) { | | 1111 | } else if (pflag) { |
1112 | /* nonportable bit-field type */ | | 1112 | /* nonportable bit-field type */ |
1113 | warning(34); | | 1113 | warning(34); |
1114 | } | | 1114 | } |
1115 | } | | 1115 | } |
1116 | } else if (t == INT && dcs->d_smod == NOTSPEC) { | | 1116 | } else if (t == INT && dcs->d_smod == NOTSPEC) { |
1117 | if (pflag && bitfieldtype_ok == 0) { | | 1117 | if (pflag && bitfieldtype_ok == 0) { |
1118 | /* nonportable bit-field type */ | | 1118 | /* nonportable bit-field type */ |
1119 | warning(34); | | 1119 | warning(34); |
1120 | } | | 1120 | } |
1121 | } else if (t != INT && t != UINT) { | | 1121 | } else if (t != INT && t != UINT && t != BOOL) { |
1122 | /* | | 1122 | /* |
1123 | * Non-integer types are always illegal for | | 1123 | * Non-integer types are always illegal for |
1124 | * bitfields, regardless of BITFIELDTYPE. | | 1124 | * bitfields, regardless of BITFIELDTYPE. |
1125 | * Integer types not dealt with above are | | 1125 | * Integer types not dealt with above are |
1126 | * okay only if BITFIELDTYPE is in effect. | | 1126 | * okay only if BITFIELDTYPE is in effect. |
1127 | */ | | 1127 | */ |
1128 | if (bitfieldtype_ok == 0 || tspec_is_int(t) == 0) { | | 1128 | if (bitfieldtype_ok == 0 || tspec_is_int(t) == 0) { |
1129 | /* illegal bit-field type */ | | 1129 | /* illegal bit-field type */ |
1130 | warning(35); | | 1130 | warning(35); |
1131 | sz = tp->t_flen; | | 1131 | sz = tp->t_flen; |
1132 | dsym->s_type = tp = duptyp(gettyp(t = INT)); | | 1132 | dsym->s_type = tp = duptyp(gettyp(t = INT)); |
1133 | if ((tp->t_flen = sz) > size(t)) | | 1133 | if ((tp->t_flen = sz) > size(t)) |
1134 | tp->t_flen = size(t); | | 1134 | tp->t_flen = size(t); |