Thu Jul 15 20:05:49 2021 UTC ()
lint: remove message 66 about missing semicolon in struct-declaration


(rillig)
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_struct_c90.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_struct_c90.exp
diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/decl_struct_member.c
diff -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/decl_struct_member.exp
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_066.c
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_066.exp
diff -r1.327 -r1.328 src/usr.bin/xlint/lint1/cgram.y
diff -r1.129 -r1.130 src/usr.bin/xlint/lint1/err.c

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_struct_c90.c (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/decl_struct_c90.c 2021/07/15 19:51:29 1.1
+++ src/tests/usr.bin/xlint/lint1/decl_struct_c90.c 2021/07/15 20:05:49 1.2
@@ -1,18 +1,21 @@ @@ -1,18 +1,21 @@
1/* $NetBSD: decl_struct_c90.c,v 1.1 2021/07/15 19:51:29 rillig Exp $ */ 1/* $NetBSD: decl_struct_c90.c,v 1.2 2021/07/15 20:05:49 rillig Exp $ */
2# 3 "decl_struct_c90.c" 2# 3 "decl_struct_c90.c"
3 3
4/* 4/*
5 * Test declaration of struct types, in C90 without any GNU extensions. 5 * Test declaration of struct types, in C90 without any GNU extensions.
6 */ 6 */
7 7
8/* lint1-flags: -sw */ 8/* lint1-flags: -sw */
9 9
10/* 10/*
11 * All of K&R, C90, C99 require that a struct member declaration is 11 * All of K&R, C90, C99 require that a struct member declaration is
12 * terminated with a semicolon. No idea why lint allows the missing 12 * terminated with a semicolon.
13 * semicolon in non-C90 mode. 13 *
 14 * Before cgram.y 1.328 from 2021-07-15, lint allowed the missing semicolon
 15 * in non-C90 mode, no idea why.
14 */ 16 */
15struct missing_semicolon { 17struct missing_semicolon {
16 int member 18 int member
17}; 19};
18/* expect-1: error: syntax requires ';' after last struct/union member [66] */ 20/* expect-1: error: syntax error '}' [249] */
 21/* expect+1: error: cannot recover from previous errors [224] */

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/decl_struct_c90.exp (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/decl_struct_c90.exp 2021/07/15 19:51:29 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/decl_struct_c90.exp 2021/07/15 20:05:49 1.2

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

--- src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2021/07/15 19:51:29 1.7
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2021/07/15 20:05:49 1.8
@@ -1,61 +1,61 @@ @@ -1,61 +1,61 @@
1/* $NetBSD: decl_struct_member.c,v 1.7 2021/07/15 19:51:29 rillig Exp $ */ 1/* $NetBSD: decl_struct_member.c,v 1.8 2021/07/15 20:05:49 rillig Exp $ */
2# 3 "decl_struct_member.c" 2# 3 "decl_struct_member.c"
3 3
4struct multi_attributes { 4struct multi_attributes {
5 __attribute__((deprecated)) 5 __attribute__((deprecated))
6 __attribute__((deprecated)) 6 __attribute__((deprecated))
7 __attribute__((deprecated)) 7 __attribute__((deprecated))
8 int deprecated; 8 int deprecated;
9}; 9};
10 10
11struct cover_begin_type_noclass_declspecs { 11struct cover_begin_type_noclass_declspecs {
12 int m1; 12 int m1;
13 __attribute__((deprecated)) int m2; 13 __attribute__((deprecated)) int m2;
14 const int m3; 14 const int m3;
15 int const m4; 15 int const m4;
16 int const long m5; 16 int const long m5;
17 int __attribute__((deprecated)) m6; 17 int __attribute__((deprecated)) m6;
18}; 18};
19 19
20typedef int number; 20typedef int number;
21 21
22struct cover_begin_type_typespec { 22struct cover_begin_type_typespec {
23 int m1; 23 int m1;
24 number m2; 24 number m2;
25}; 25};
26 26
27struct cover_begin_type_noclass_declmods { 27struct cover_begin_type_noclass_declmods {
28 const m1; 28 const m1;
29 const volatile m2; 29 const volatile m2;
30}; 30};
31 31
32/* cover struct_or_union_specifier: struct_or_union error */ 32/* cover struct_or_union_specifier: struct_or_union error */
33/* expect+1: error: syntax error 'goto' [249] */ 33/* expect+1: error: syntax error 'goto' [249] */
34struct goto { 34struct goto {
35 /* expect+1: error: illegal type combination [4] */ 35 /* expect+1: error: illegal type combination [4] */
36 int member; 36 int member;
37 /* expect+1: error: syntax error '}' [249] */ 37 /* expect+1: error: syntax error '}' [249] */
38}; 38};
39/* expect-1: warning: empty declaration [0] */ 39/* expect-1: warning: empty declaration [0] */
40 40
41/* 41/*
42 * Before cgram.y 1.228 from 2021-06-19, lint ran into an assertion failure: 42 * Before cgram.y 1.228 from 2021-06-19, lint ran into an assertion failure:
43 * 43 *
44 * "is_struct_or_union(dcs->d_type->t_tspec)" at cgram.y:846 44 * "is_struct_or_union(dcs->d_type->t_tspec)" at cgram.y:846
45 */ 45 */
46struct { 46struct {
47 char; /* expect: syntax error 'unnamed member' */ 47 char; /* expect: syntax error 'unnamed member' */
48}; 48};
49 49
50/* 50/*
51 * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault. 51 * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault.
52 */ 52 */
53struct { 53struct {
54 char a(_)0 /* expect: syntax error '0' */ 54 char a(_)0 /* expect: syntax error '0' */
55} /* expect: ';' after last */ 55}
56/* 56/*
57 * FIXME: adding a semicolon here triggers another assertion: 57 * FIXME: adding a semicolon here triggers another assertion:
58 * 58 *
59 * assertion "t == NOTSPEC" failed in end_type at decl.c:774 59 * assertion "t == NOTSPEC" failed in end_type at decl.c:774
60 */ 60 */
61/* expect+1: cannot recover from previous errors */ 61/* expect+1: cannot recover from previous errors */

cvs diff -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/Attic/decl_struct_member.exp (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/decl_struct_member.exp 2021/07/15 19:51:29 1.6
+++ src/tests/usr.bin/xlint/lint1/Attic/decl_struct_member.exp 2021/07/15 20:05:49 1.7
@@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
1decl_struct_member.c(34): error: syntax error 'goto' [249] 1decl_struct_member.c(34): error: syntax error 'goto' [249]
2decl_struct_member.c(36): error: illegal type combination [4] 2decl_struct_member.c(36): error: illegal type combination [4]
3decl_struct_member.c(38): error: syntax error '}' [249] 3decl_struct_member.c(38): error: syntax error '}' [249]
4decl_struct_member.c(38): warning: empty declaration [0] 4decl_struct_member.c(38): warning: empty declaration [0]
5decl_struct_member.c(47): error: syntax error 'unnamed member' [249] 5decl_struct_member.c(47): error: syntax error 'unnamed member' [249]
6decl_struct_member.c(54): error: syntax error '0' [249] 6decl_struct_member.c(54): error: syntax error '0' [249]
7decl_struct_member.c(55): warning: syntax requires ';' after last struct/union member [66] 
8decl_struct_member.c(62): error: cannot recover from previous errors [224] 7decl_struct_member.c(62): error: cannot recover from previous errors [224]

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_066.c (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_066.c 2021/01/31 11:12:07 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_066.c 2021/07/15 20:05:49 1.4
@@ -1,8 +1,15 @@ @@ -1,8 +1,15 @@
1/* $NetBSD: msg_066.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */ 1/* $NetBSD: msg_066.c,v 1.4 2021/07/15 20:05:49 rillig Exp $ */
2# 3 "msg_066.c" 2# 3 "msg_066.c"
3 3
4// Test for message: syntax requires ';' after last struct/union member [66] 4// Test for message: syntax requires ';' after last struct/union member [66]
5 5
 6/*
 7 * This message was removed in cgram.y 1.328 from 2021-07-15 because all
 8 * C standards and even K&R require a semicolon.
 9 */
 10
6struct number { 11struct number {
7 int value 12 int value
8}; /* expect: 66 */ 13};
 14/* expect-1: syntax error '}' [249] */
 15/* expect+1: error: cannot recover from previous errors [224] */

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/Attic/msg_066.exp (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_066.exp 2021/01/08 21:25:03 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_066.exp 2021/07/15 20:05:49 1.3

cvs diff -r1.327 -r1.328 src/usr.bin/xlint/lint1/cgram.y (switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/15 18:18:15 1.327
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/15 20:05:49 1.328
@@ -1,1992 +1,1983 @@ @@ -1,1992 +1,1983 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.327 2021/07/15 18:18:15 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software 17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement: 18 * must display the following acknowledgement:
19 * This product includes software developed by Jochen Pohl for 19 * This product includes software developed by Jochen Pohl for
20 * The NetBSD Project. 20 * The NetBSD Project.
21 * 4. The name of the author may not be used to endorse or promote products 21 * 4. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission. 22 * derived from this software without specific prior written permission.
23 * 23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint) 37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: cgram.y,v 1.327 2021/07/15 18:18:15 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $");
39#endif 39#endif
40 40
41#include <limits.h> 41#include <limits.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <string.h> 43#include <string.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48 48
49/* 49/*
50 * Contains the level of current declaration, used for symbol table entries. 50 * Contains the level of current declaration, used for symbol table entries.
51 * 0 is the top-level, > 0 is inside a function body. 51 * 0 is the top-level, > 0 is inside a function body.
52 */ 52 */
53int block_level; 53int block_level;
54 54
55/* 55/*
56 * level for memory allocation. Normally the same as block_level. 56 * level for memory allocation. Normally the same as block_level.
57 * An exception is the declaration of arguments in prototypes. Memory 57 * An exception is the declaration of arguments in prototypes. Memory
58 * for these can't be freed after the declaration, but symbols must 58 * for these can't be freed after the declaration, but symbols must
59 * be removed from the symbol table after the declaration. 59 * be removed from the symbol table after the declaration.
60 */ 60 */
61int mem_block_level; 61int mem_block_level;
62 62
63/* 63/*
64 * Save the no-warns state and restore it to avoid the problem where 64 * Save the no-warns state and restore it to avoid the problem where
65 * if (expr) { stmt } / * NOLINT * / stmt; 65 * if (expr) { stmt } / * NOLINT * / stmt;
66 */ 66 */
67static int olwarn = LWARN_BAD; 67static int olwarn = LWARN_BAD;
68 68
69static void cgram_declare(sym_t *, bool, sbuf_t *); 69static void cgram_declare(sym_t *, bool, sbuf_t *);
70static void ignore_up_to_rparen(void); 70static void ignore_up_to_rparen(void);
71static sym_t *symbolrename(sym_t *, sbuf_t *); 71static sym_t *symbolrename(sym_t *, sbuf_t *);
72 72
73 73
74#ifdef DEBUG 74#ifdef DEBUG
75static void 75static void
76CLEAR_WARN_FLAGS(const char *file, size_t line) 76CLEAR_WARN_FLAGS(const char *file, size_t line)
77{ 77{
78 printf("%s:%d: %s:%zu: clearing flags\n", 78 printf("%s:%d: %s:%zu: clearing flags\n",
79 curr_pos.p_file, curr_pos.p_line, file, line); 79 curr_pos.p_file, curr_pos.p_line, file, line);
80 clear_warn_flags(); 80 clear_warn_flags();
81 olwarn = LWARN_BAD; 81 olwarn = LWARN_BAD;
82} 82}
83 83
84static void 84static void
85SAVE_WARN_FLAGS(const char *file, size_t line) 85SAVE_WARN_FLAGS(const char *file, size_t line)
86{ 86{
87 lint_assert(olwarn == LWARN_BAD); 87 lint_assert(olwarn == LWARN_BAD);
88 printf("%s:%d: %s:%zu: saving flags %d\n", 88 printf("%s:%d: %s:%zu: saving flags %d\n",
89 curr_pos.p_file, curr_pos.p_line, file, line, lwarn); 89 curr_pos.p_file, curr_pos.p_line, file, line, lwarn);
90 olwarn = lwarn; 90 olwarn = lwarn;
91} 91}
92 92
93static void 93static void
94RESTORE_WARN_FLAGS(const char *file, size_t line) 94RESTORE_WARN_FLAGS(const char *file, size_t line)
95{ 95{
96 if (olwarn != LWARN_BAD) { 96 if (olwarn != LWARN_BAD) {
97 lwarn = olwarn; 97 lwarn = olwarn;
98 printf("%s:%d: %s:%zu: restoring flags %d\n", 98 printf("%s:%d: %s:%zu: restoring flags %d\n",
99 curr_pos.p_file, curr_pos.p_line, file, line, lwarn); 99 curr_pos.p_file, curr_pos.p_line, file, line, lwarn);
100 olwarn = LWARN_BAD; 100 olwarn = LWARN_BAD;
101 } else 101 } else
102 CLEAR_WARN_FLAGS(file, line); 102 CLEAR_WARN_FLAGS(file, line);
103} 103}
104#define cgram_debug(fmt, args...) printf("cgram_debug: " fmt "\n", ##args) 104#define cgram_debug(fmt, args...) printf("cgram_debug: " fmt "\n", ##args)
105#else 105#else
106#define CLEAR_WARN_FLAGS(f, l) clear_warn_flags(), olwarn = LWARN_BAD 106#define CLEAR_WARN_FLAGS(f, l) clear_warn_flags(), olwarn = LWARN_BAD
107#define SAVE_WARN_FLAGS(f, l) olwarn = lwarn 107#define SAVE_WARN_FLAGS(f, l) olwarn = lwarn
108#define RESTORE_WARN_FLAGS(f, l) \ 108#define RESTORE_WARN_FLAGS(f, l) \
109 (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn)) 109 (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn))
110#define cgram_debug(fmt, args...) do { } while (false) 110#define cgram_debug(fmt, args...) do { } while (false)
111#endif 111#endif
112 112
113#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__) 113#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__)
114#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) 114#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__)
115#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) 115#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__)
116 116
117/* unbind the anonymous struct members from the struct */ 117/* unbind the anonymous struct members from the struct */
118static void 118static void
119anonymize(sym_t *s) 119anonymize(sym_t *s)
120{ 120{
121 for ( ; s != NULL; s = s->s_next) 121 for ( ; s != NULL; s = s->s_next)
122 s->s_styp = NULL; 122 s->s_styp = NULL;
123} 123}
124 124
125%} 125%}
126 126
127%expect 165 127%expect 165
128 128
129%union { 129%union {
130 val_t *y_val; 130 val_t *y_val;
131 sbuf_t *y_name; 131 sbuf_t *y_name;
132 sym_t *y_sym; 132 sym_t *y_sym;
133 op_t y_op; 133 op_t y_op;
134 scl_t y_scl; 134 scl_t y_scl;
135 tspec_t y_tspec; 135 tspec_t y_tspec;
136 tqual_t y_tqual; 136 tqual_t y_tqual;
137 type_t *y_type; 137 type_t *y_type;
138 tnode_t *y_tnode; 138 tnode_t *y_tnode;
139 range_t y_range; 139 range_t y_range;
140 strg_t *y_string; 140 strg_t *y_string;
141 qual_ptr *y_qual_ptr; 141 qual_ptr *y_qual_ptr;
142 bool y_seen_statement; 142 bool y_seen_statement;
143 struct generic_association *y_generic; 143 struct generic_association *y_generic;
144}; 144};
145 145
146%token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPAREN T_RPAREN 146%token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPAREN T_RPAREN
147%token T_POINT T_ARROW 147%token T_POINT T_ARROW
148%token T_COMPLEMENT T_LOGNOT 148%token T_COMPLEMENT T_LOGNOT
149%token <y_op> T_INCDEC 149%token <y_op> T_INCDEC
150%token T_SIZEOF 150%token T_SIZEOF
151%token T_BUILTIN_OFFSETOF 151%token T_BUILTIN_OFFSETOF
152%token T_TYPEOF 152%token T_TYPEOF
153%token T_EXTENSION 153%token T_EXTENSION
154%token T_ALIGNAS 154%token T_ALIGNAS
155%token T_ALIGNOF 155%token T_ALIGNOF
156%token T_ASTERISK 156%token T_ASTERISK
157%token <y_op> T_MULTIPLICATIVE 157%token <y_op> T_MULTIPLICATIVE
158%token <y_op> T_ADDITIVE 158%token <y_op> T_ADDITIVE
159%token <y_op> T_SHIFT 159%token <y_op> T_SHIFT
160%token <y_op> T_RELATIONAL 160%token <y_op> T_RELATIONAL
161%token <y_op> T_EQUALITY 161%token <y_op> T_EQUALITY
162%token T_AMPER 162%token T_AMPER
163%token T_BITXOR 163%token T_BITXOR
164%token T_BITOR 164%token T_BITOR
165%token T_LOGAND 165%token T_LOGAND
166%token T_LOGOR 166%token T_LOGOR
167%token T_QUEST 167%token T_QUEST
168%token T_COLON 168%token T_COLON
169%token T_ASSIGN 169%token T_ASSIGN
170%token <y_op> T_OPASSIGN 170%token <y_op> T_OPASSIGN
171%token T_COMMA 171%token T_COMMA
172%token T_SEMI 172%token T_SEMI
173%token T_ELLIPSIS 173%token T_ELLIPSIS
174%token T_REAL 174%token T_REAL
175%token T_IMAG 175%token T_IMAG
176%token T_GENERIC 176%token T_GENERIC
177%token T_NORETURN 177%token T_NORETURN
178 178
179/* storage classes (extern, static, auto, register and typedef) */ 179/* storage classes (extern, static, auto, register and typedef) */
180%token <y_scl> T_SCLASS 180%token <y_scl> T_SCLASS
181 181
182/* 182/*
183 * predefined type keywords (char, int, short, long, unsigned, signed, 183 * predefined type keywords (char, int, short, long, unsigned, signed,
184 * float, double, void); see T_TYPENAME for types from typedef 184 * float, double, void); see T_TYPENAME for types from typedef
185 */ 185 */
186%token <y_tspec> T_TYPE 186%token <y_tspec> T_TYPE
187 187
188/* qualifiers (const, volatile, restrict, _Thread_local) */ 188/* qualifiers (const, volatile, restrict, _Thread_local) */
189%token <y_tqual> T_QUAL 189%token <y_tqual> T_QUAL
190 190
191/* struct or union */ 191/* struct or union */
192%token <y_tspec> T_STRUCT_OR_UNION 192%token <y_tspec> T_STRUCT_OR_UNION
193 193
194/* remaining keywords */ 194/* remaining keywords */
195%token T_ASM 195%token T_ASM
196%token T_BREAK 196%token T_BREAK
197%token T_CASE 197%token T_CASE
198%token T_CONTINUE 198%token T_CONTINUE
199%token T_DEFAULT 199%token T_DEFAULT
200%token T_DO 200%token T_DO
201%token T_ELSE 201%token T_ELSE
202%token T_ENUM 202%token T_ENUM
203%token T_FOR 203%token T_FOR
204%token T_GOTO 204%token T_GOTO
205%token T_IF 205%token T_IF
206%token T_PACKED 206%token T_PACKED
207%token T_RETURN 207%token T_RETURN
208%token T_SWITCH 208%token T_SWITCH
209%token T_SYMBOLRENAME 209%token T_SYMBOLRENAME
210%token T_WHILE 210%token T_WHILE
211 211
212%token T_ATTRIBUTE 212%token T_ATTRIBUTE
213%token T_AT_ALIAS 213%token T_AT_ALIAS
214%token T_AT_ALIGNED 214%token T_AT_ALIGNED
215%token T_AT_ALLOC_SIZE 215%token T_AT_ALLOC_SIZE
216%token T_AT_ALWAYS_INLINE 216%token T_AT_ALWAYS_INLINE
217%token T_AT_BOUNDED 217%token T_AT_BOUNDED
218%token T_AT_BUFFER 218%token T_AT_BUFFER
219%token T_AT_COLD 219%token T_AT_COLD
220%token T_AT_COMMON 220%token T_AT_COMMON
221%token T_AT_CONSTRUCTOR 221%token T_AT_CONSTRUCTOR
222%token T_AT_DEPRECATED 222%token T_AT_DEPRECATED
223%token T_AT_DESTRUCTOR 223%token T_AT_DESTRUCTOR
224%token T_AT_FALLTHROUGH 224%token T_AT_FALLTHROUGH
225%token T_AT_FORMAT 225%token T_AT_FORMAT
226%token T_AT_FORMAT_ARG 226%token T_AT_FORMAT_ARG
227%token T_AT_FORMAT_GNU_PRINTF 227%token T_AT_FORMAT_GNU_PRINTF
228%token T_AT_FORMAT_PRINTF 228%token T_AT_FORMAT_PRINTF
229%token T_AT_FORMAT_SCANF 229%token T_AT_FORMAT_SCANF
230%token T_AT_FORMAT_STRFMON 230%token T_AT_FORMAT_STRFMON
231%token T_AT_FORMAT_STRFTIME 231%token T_AT_FORMAT_STRFTIME
232%token T_AT_FORMAT_SYSLOG 232%token T_AT_FORMAT_SYSLOG
233%token T_AT_GNU_INLINE 233%token T_AT_GNU_INLINE
234%token T_AT_HOT 234%token T_AT_HOT
235%token T_AT_MALLOC 235%token T_AT_MALLOC
236%token T_AT_MAY_ALIAS 236%token T_AT_MAY_ALIAS
237%token T_AT_MINBYTES 237%token T_AT_MINBYTES
238%token T_AT_MODE 238%token T_AT_MODE
239%token T_AT_NOINLINE 239%token T_AT_NOINLINE
240%token T_AT_NONNULL 240%token T_AT_NONNULL
241%token T_AT_NONSTRING 241%token T_AT_NONSTRING
242%token T_AT_NORETURN 242%token T_AT_NORETURN
243%token T_AT_NOTHROW 243%token T_AT_NOTHROW
244%token T_AT_NO_INSTRUMENT_FUNCTION 244%token T_AT_NO_INSTRUMENT_FUNCTION
245%token T_AT_OPTIMIZE 245%token T_AT_OPTIMIZE
246%token T_AT_PACKED 246%token T_AT_PACKED
247%token T_AT_PCS 247%token T_AT_PCS
248%token T_AT_PURE 248%token T_AT_PURE
249%token T_AT_RETURNS_TWICE 249%token T_AT_RETURNS_TWICE
250%token T_AT_SECTION 250%token T_AT_SECTION
251%token T_AT_SENTINEL 251%token T_AT_SENTINEL
252%token T_AT_STRING 252%token T_AT_STRING
253%token T_AT_TLS_MODEL 253%token T_AT_TLS_MODEL
254%token T_AT_TUNION 254%token T_AT_TUNION
255%token T_AT_UNUSED 255%token T_AT_UNUSED
256%token T_AT_USED 256%token T_AT_USED
257%token T_AT_VISIBILITY 257%token T_AT_VISIBILITY
258%token T_AT_WARN_UNUSED_RESULT 258%token T_AT_WARN_UNUSED_RESULT
259%token T_AT_WEAK 259%token T_AT_WEAK
260 260
261%left T_THEN 261%left T_THEN
262%left T_ELSE 262%left T_ELSE
263%left T_COMMA 263%left T_COMMA
264%right T_ASSIGN T_OPASSIGN 264%right T_ASSIGN T_OPASSIGN
265%right T_QUEST T_COLON 265%right T_QUEST T_COLON
266%left T_LOGOR 266%left T_LOGOR
267%left T_LOGAND 267%left T_LOGAND
268%left T_BITOR 268%left T_BITOR
269%left T_BITXOR 269%left T_BITXOR
270%left T_AMPER 270%left T_AMPER
271%left T_EQUALITY 271%left T_EQUALITY
272%left T_RELATIONAL 272%left T_RELATIONAL
273%left T_SHIFT 273%left T_SHIFT
274%left T_ADDITIVE 274%left T_ADDITIVE
275%left T_ASTERISK T_MULTIPLICATIVE 275%left T_ASTERISK T_MULTIPLICATIVE
276 276
277%token <y_name> T_NAME 277%token <y_name> T_NAME
278%token <y_name> T_TYPENAME 278%token <y_name> T_TYPENAME
279%token <y_val> T_CON 279%token <y_val> T_CON
280%token <y_string> T_STRING 280%token <y_string> T_STRING
281 281
282%type <y_sym> identifier_sym 282%type <y_sym> identifier_sym
283%type <y_name> identifier 283%type <y_name> identifier
284%type <y_string> string 284%type <y_string> string
285%type <y_string> string2 285%type <y_string> string2
286 286
287%type <y_tnode> primary_expression 287%type <y_tnode> primary_expression
288%type <y_tnode> generic_selection 288%type <y_tnode> generic_selection
289%type <y_generic> generic_assoc_list 289%type <y_generic> generic_assoc_list
290%type <y_generic> generic_association 290%type <y_generic> generic_association
291%type <y_tnode> postfix_expression 291%type <y_tnode> postfix_expression
292%type <y_tnode> gcc_statement_expr_list 292%type <y_tnode> gcc_statement_expr_list
293%type <y_tnode> gcc_statement_expr_item 293%type <y_tnode> gcc_statement_expr_item
294%type <y_op> point_or_arrow 294%type <y_op> point_or_arrow
295%type <y_tnode> argument_expression_list 295%type <y_tnode> argument_expression_list
296%type <y_tnode> unary_expression 296%type <y_tnode> unary_expression
297%type <y_tnode> cast_expression 297%type <y_tnode> cast_expression
298%type <y_tnode> conditional_expression 298%type <y_tnode> conditional_expression
299%type <y_tnode> assignment_expression 299%type <y_tnode> assignment_expression
300%type <y_tnode> expression_opt 300%type <y_tnode> expression_opt
301%type <y_tnode> expression 301%type <y_tnode> expression
302%type <y_tnode> constant_expr 302%type <y_tnode> constant_expr
303 303
304%type <y_type> begin_type_typespec 304%type <y_type> begin_type_typespec
305%type <y_type> type_specifier 305%type <y_type> type_specifier
306%type <y_type> notype_type_specifier 306%type <y_type> notype_type_specifier
307%type <y_type> struct_or_union_specifier 307%type <y_type> struct_or_union_specifier
308%type <y_tspec> struct_or_union 308%type <y_tspec> struct_or_union
309%type <y_sym> braced_struct_declaration_list 309%type <y_sym> braced_struct_declaration_list
310%type <y_sym> struct_declaration_list_with_rbrace 310%type <y_sym> struct_declaration_list_with_rbrace
311%type <y_sym> struct_declaration_list 311%type <y_sym> struct_declaration_list
312%type <y_sym> struct_declaration 312%type <y_sym> struct_declaration
313%type <y_sym> notype_struct_declarators 313%type <y_sym> notype_struct_declarators
314%type <y_sym> type_struct_declarators 314%type <y_sym> type_struct_declarators
315%type <y_sym> notype_struct_declarator 315%type <y_sym> notype_struct_declarator
316%type <y_sym> type_struct_declarator 316%type <y_sym> type_struct_declarator
317%type <y_type> enum_specifier 317%type <y_type> enum_specifier
318%type <y_sym> enum_declaration 318%type <y_sym> enum_declaration
319%type <y_sym> enums_with_opt_comma 319%type <y_sym> enums_with_opt_comma
320%type <y_sym> enumerator_list 320%type <y_sym> enumerator_list
321%type <y_sym> enumerator 321%type <y_sym> enumerator
322%type <y_qual_ptr> type_qualifier 322%type <y_qual_ptr> type_qualifier
323%type <y_qual_ptr> pointer 323%type <y_qual_ptr> pointer
324%type <y_qual_ptr> asterisk 324%type <y_qual_ptr> asterisk
325%type <y_qual_ptr> type_qualifier_list_opt 325%type <y_qual_ptr> type_qualifier_list_opt
326%type <y_qual_ptr> type_qualifier_list 326%type <y_qual_ptr> type_qualifier_list
327%type <y_sym> notype_declarator 327%type <y_sym> notype_declarator
328%type <y_sym> type_declarator 328%type <y_sym> type_declarator
329%type <y_sym> notype_direct_declarator 329%type <y_sym> notype_direct_declarator
330%type <y_sym> type_direct_declarator 330%type <y_sym> type_direct_declarator
331%type <y_sym> type_param_declarator 331%type <y_sym> type_param_declarator
332%type <y_sym> notype_param_declarator 332%type <y_sym> notype_param_declarator
333%type <y_sym> direct_param_declarator 333%type <y_sym> direct_param_declarator
334%type <y_sym> direct_notype_param_declarator 334%type <y_sym> direct_notype_param_declarator
335%type <y_sym> param_list 335%type <y_sym> param_list
336%type <y_tnode> array_size 336%type <y_tnode> array_size
337%type <y_sym> identifier_list 337%type <y_sym> identifier_list
338%type <y_type> type_name 338%type <y_type> type_name
339%type <y_sym> abstract_declaration 339%type <y_sym> abstract_declaration
340%type <y_sym> abstract_declarator 340%type <y_sym> abstract_declarator
341%type <y_sym> direct_abstract_declarator 341%type <y_sym> direct_abstract_declarator
342%type <y_sym> abstract_decl_param_list 342%type <y_sym> abstract_decl_param_list
343%type <y_sym> vararg_parameter_type_list 343%type <y_sym> vararg_parameter_type_list
344%type <y_sym> parameter_type_list 344%type <y_sym> parameter_type_list
345%type <y_sym> parameter_declaration 345%type <y_sym> parameter_declaration
346%type <y_range> range 346%type <y_range> range
347%type <y_name> asm_or_symbolrename_opt 347%type <y_name> asm_or_symbolrename_opt
348 348
349%type <y_seen_statement> block_item_list 349%type <y_seen_statement> block_item_list
350%type <y_seen_statement> block_item 350%type <y_seen_statement> block_item
351%type <y_tnode> do_while_expr 351%type <y_tnode> do_while_expr
352%type <y_sym> func_declarator 352%type <y_sym> func_declarator
353 353
354%% 354%%
355 355
356program: 356program:
357 /* empty */ { 357 /* empty */ {
358 if (sflag) { 358 if (sflag) {
359 /* empty translation unit */ 359 /* empty translation unit */
360 error(272); 360 error(272);
361 } else if (!tflag) { 361 } else if (!tflag) {
362 /* empty translation unit */ 362 /* empty translation unit */
363 warning(272); 363 warning(272);
364 } 364 }
365 } 365 }
366 | translation_unit 366 | translation_unit
367 ; 367 ;
368 368
369identifier_sym: /* helper for struct/union/enum */ 369identifier_sym: /* helper for struct/union/enum */
370 identifier { 370 identifier {
371 $$ = getsym($1); 371 $$ = getsym($1);
372 } 372 }
373 ; 373 ;
374 374
375/* K&R ???, C90 ???, C99 6.4.2.1, C11 ??? */ 375/* K&R ???, C90 ???, C99 6.4.2.1, C11 ??? */
376identifier: 376identifier:
377 T_NAME { 377 T_NAME {
378 $$ = $1; 378 $$ = $1;
379 cgram_debug("name '%s'", $$->sb_name); 379 cgram_debug("name '%s'", $$->sb_name);
380 } 380 }
381 | T_TYPENAME { 381 | T_TYPENAME {
382 $$ = $1; 382 $$ = $1;
383 cgram_debug("typename '%s'", $$->sb_name); 383 cgram_debug("typename '%s'", $$->sb_name);
384 } 384 }
385 ; 385 ;
386 386
387/* see C99 6.4.5, string literals are joined by 5.1.1.2 */ 387/* see C99 6.4.5, string literals are joined by 5.1.1.2 */
388string: 388string:
389 T_STRING 389 T_STRING
390 | T_STRING string2 { 390 | T_STRING string2 {
391 $$ = cat_strings($1, $2); 391 $$ = cat_strings($1, $2);
392 } 392 }
393 ; 393 ;
394 394
395/* see C99 6.4.5, string literals are joined by 5.1.1.2 */ 395/* see C99 6.4.5, string literals are joined by 5.1.1.2 */
396string2: 396string2:
397 T_STRING { 397 T_STRING {
398 if (tflag) { 398 if (tflag) {
399 /* concatenated strings are illegal in traditional C */ 399 /* concatenated strings are illegal in traditional C */
400 warning(219); 400 warning(219);
401 } 401 }
402 $$ = $1; 402 $$ = $1;
403 } 403 }
404 | string2 T_STRING { 404 | string2 T_STRING {
405 $$ = cat_strings($1, $2); 405 $$ = cat_strings($1, $2);
406 } 406 }
407 ; 407 ;
408 408
409/* K&R 7.1, C90 ???, C99 6.5.1, C11 6.5.1 */ 409/* K&R 7.1, C90 ???, C99 6.5.1, C11 6.5.1 */
410primary_expression: 410primary_expression:
411 T_NAME { 411 T_NAME {
412 /* XXX really necessary? */ 412 /* XXX really necessary? */
413 if (yychar < 0) 413 if (yychar < 0)
414 yychar = yylex(); 414 yychar = yylex();
415 $$ = new_name_node(getsym($1), yychar); 415 $$ = new_name_node(getsym($1), yychar);
416 } 416 }
417 | T_CON { 417 | T_CON {
418 $$ = expr_new_constant(gettyp($1->v_tspec), $1); 418 $$ = expr_new_constant(gettyp($1->v_tspec), $1);
419 } 419 }
420 | string { 420 | string {
421 $$ = new_string_node($1); 421 $$ = new_string_node($1);
422 } 422 }
423 | T_LPAREN expression T_RPAREN { 423 | T_LPAREN expression T_RPAREN {
424 if ($2 != NULL) 424 if ($2 != NULL)
425 $2->tn_parenthesized = true; 425 $2->tn_parenthesized = true;
426 $$ = $2; 426 $$ = $2;
427 } 427 }
428 | generic_selection 428 | generic_selection
429 /* GCC primary-expression, see c_parser_postfix_expression */ 429 /* GCC primary-expression, see c_parser_postfix_expression */
430 | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN { 430 | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {
431 symtyp = FMEMBER; 431 symtyp = FMEMBER;
432 $$ = build_offsetof($3, getsym($5)); 432 $$ = build_offsetof($3, getsym($5));
433 } 433 }
434 ; 434 ;
435 435
436/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ 436/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
437generic_selection: 437generic_selection:
438 T_GENERIC T_LPAREN assignment_expression T_COMMA 438 T_GENERIC T_LPAREN assignment_expression T_COMMA
439 generic_assoc_list T_RPAREN { 439 generic_assoc_list T_RPAREN {
440 /* generic selection requires C11 or later */ 440 /* generic selection requires C11 or later */
441 c11ism(345); 441 c11ism(345);
442 $$ = build_generic_selection($3, $5); 442 $$ = build_generic_selection($3, $5);
443 } 443 }
444 ; 444 ;
445 445
446/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ 446/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
447generic_assoc_list: 447generic_assoc_list:
448 generic_association 448 generic_association
449 | generic_assoc_list T_COMMA generic_association { 449 | generic_assoc_list T_COMMA generic_association {
450 $3->ga_prev = $1; 450 $3->ga_prev = $1;
451 $$ = $3; 451 $$ = $3;
452 } 452 }
453 ; 453 ;
454 454
455/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ 455/* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */
456generic_association: 456generic_association:
457 type_name T_COLON assignment_expression { 457 type_name T_COLON assignment_expression {
458 $$ = getblk(sizeof(*$$)); 458 $$ = getblk(sizeof(*$$));
459 $$->ga_arg = $1; 459 $$->ga_arg = $1;
460 $$->ga_result = $3; 460 $$->ga_result = $3;
461 } 461 }
462 | T_DEFAULT T_COLON assignment_expression { 462 | T_DEFAULT T_COLON assignment_expression {
463 $$ = getblk(sizeof(*$$)); 463 $$ = getblk(sizeof(*$$));
464 $$->ga_arg = NULL; 464 $$->ga_arg = NULL;
465 $$->ga_result = $3; 465 $$->ga_result = $3;
466 } 466 }
467 ; 467 ;
468 468
469/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ 469/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */
470postfix_expression: 470postfix_expression:
471 primary_expression 471 primary_expression
472 | postfix_expression T_LBRACK expression T_RBRACK { 472 | postfix_expression T_LBRACK expression T_RBRACK {
473 $$ = build(INDIR, build(PLUS, $1, $3), NULL); 473 $$ = build(INDIR, build(PLUS, $1, $3), NULL);
474 } 474 }
475 | postfix_expression T_LPAREN T_RPAREN { 475 | postfix_expression T_LPAREN T_RPAREN {
476 $$ = new_function_call_node($1, NULL); 476 $$ = new_function_call_node($1, NULL);
477 } 477 }
478 | postfix_expression T_LPAREN argument_expression_list T_RPAREN { 478 | postfix_expression T_LPAREN argument_expression_list T_RPAREN {
479 $$ = new_function_call_node($1, $3); 479 $$ = new_function_call_node($1, $3);
480 } 480 }
481 | postfix_expression point_or_arrow T_NAME { 481 | postfix_expression point_or_arrow T_NAME {
482 $$ = build_member_access($1, $2, $3); 482 $$ = build_member_access($1, $2, $3);
483 } 483 }
484 | postfix_expression T_INCDEC { 484 | postfix_expression T_INCDEC {
485 $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL); 485 $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
486 } 486 }
487 | T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */ 487 | T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */
488 sym_t *tmp = mktempsym($2); 488 sym_t *tmp = mktempsym($2);
489 begin_initialization(tmp); 489 begin_initialization(tmp);
490 cgram_declare(tmp, true, NULL); 490 cgram_declare(tmp, true, NULL);
491 } init_lbrace initializer_list comma_opt init_rbrace { 491 } init_lbrace initializer_list comma_opt init_rbrace {
492 if (!Sflag) 492 if (!Sflag)
493 /* compound literals are a C9X/GCC extension */ 493 /* compound literals are a C9X/GCC extension */
494 gnuism(319); 494 gnuism(319);
495 $$ = new_name_node(*current_initsym(), 0); 495 $$ = new_name_node(*current_initsym(), 0);
496 end_initialization(); 496 end_initialization();
497 } 497 }
498 | T_LPAREN compound_statement_lbrace gcc_statement_expr_list { 498 | T_LPAREN compound_statement_lbrace gcc_statement_expr_list {
499 block_level--; 499 block_level--;
500 mem_block_level--; 500 mem_block_level--;
501 begin_initialization(mktempsym(dup_type($3->tn_type))); 501 begin_initialization(mktempsym(dup_type($3->tn_type)));
502 mem_block_level++; 502 mem_block_level++;
503 block_level++; 503 block_level++;
504 /* ({ }) is a GCC extension */ 504 /* ({ }) is a GCC extension */
505 gnuism(320); 505 gnuism(320);
506 } compound_statement_rbrace T_RPAREN { 506 } compound_statement_rbrace T_RPAREN {
507 $$ = new_name_node(*current_initsym(), 0); 507 $$ = new_name_node(*current_initsym(), 0);
508 end_initialization(); 508 end_initialization();
509 } 509 }
510 ; 510 ;
511 511
512comma_opt: /* helper for 'postfix_expression' */ 512comma_opt: /* helper for 'postfix_expression' */
513 /* empty */ 513 /* empty */
514 | T_COMMA 514 | T_COMMA
515 ; 515 ;
516 516
517/* 517/*
518 * The inner part of a GCC statement-expression of the form ({ ... }). 518 * The inner part of a GCC statement-expression of the form ({ ... }).
519 * 519 *
520 * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html 520 * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
521 */ 521 */
522gcc_statement_expr_list: 522gcc_statement_expr_list:
523 gcc_statement_expr_item 523 gcc_statement_expr_item
524 | gcc_statement_expr_list gcc_statement_expr_item { 524 | gcc_statement_expr_list gcc_statement_expr_item {
525 $$ = $2; 525 $$ = $2;
526 } 526 }
527 ; 527 ;
528 528
529gcc_statement_expr_item: 529gcc_statement_expr_item:
530 declaration_or_error { 530 declaration_or_error {
531 clear_warning_flags(); 531 clear_warning_flags();
532 $$ = NULL; 532 $$ = NULL;
533 } 533 }
534 | non_expr_statement { 534 | non_expr_statement {
535 $$ = expr_zalloc_tnode(); 535 $$ = expr_zalloc_tnode();
536 $$->tn_type = gettyp(VOID); 536 $$->tn_type = gettyp(VOID);
537 } 537 }
538 | expression T_SEMI { 538 | expression T_SEMI {
539 if ($1 == NULL) { /* in case of syntax errors */ 539 if ($1 == NULL) { /* in case of syntax errors */
540 $$ = expr_zalloc_tnode(); 540 $$ = expr_zalloc_tnode();
541 $$->tn_type = gettyp(VOID); 541 $$->tn_type = gettyp(VOID);
542 } else { 542 } else {
543 /* XXX: do that only on the last name */ 543 /* XXX: do that only on the last name */
544 if ($1->tn_op == NAME) 544 if ($1->tn_op == NAME)
545 $1->tn_sym->s_used = true; 545 $1->tn_sym->s_used = true;
546 $$ = $1; 546 $$ = $1;
547 expr($1, false, false, false, false); 547 expr($1, false, false, false, false);
548 seen_fallthrough = false; 548 seen_fallthrough = false;
549 } 549 }
550 } 550 }
551 ; 551 ;
552 552
553point_or_arrow: /* helper for 'postfix_expression' */ 553point_or_arrow: /* helper for 'postfix_expression' */
554 T_POINT { 554 T_POINT {
555 symtyp = FMEMBER; 555 symtyp = FMEMBER;
556 $$ = POINT; 556 $$ = POINT;
557 } 557 }
558 | T_ARROW { 558 | T_ARROW {
559 symtyp = FMEMBER; 559 symtyp = FMEMBER;
560 $$ = ARROW; 560 $$ = ARROW;
561 } 561 }
562 ; 562 ;
563 563
564/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ 564/* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */
565argument_expression_list: 565argument_expression_list:
566 assignment_expression { 566 assignment_expression {
567 $$ = new_function_argument_node(NULL, $1); 567 $$ = new_function_argument_node(NULL, $1);
568 } 568 }
569 | argument_expression_list T_COMMA assignment_expression { 569 | argument_expression_list T_COMMA assignment_expression {
570 $$ = new_function_argument_node($1, $3); 570 $$ = new_function_argument_node($1, $3);
571 } 571 }
572 ; 572 ;
573 573
574/* K&R 7.2, C90 ???, C99 6.5.3, C11 6.5.3 */ 574/* K&R 7.2, C90 ???, C99 6.5.3, C11 6.5.3 */
575unary_expression: 575unary_expression:
576 postfix_expression 576 postfix_expression
577 | T_INCDEC unary_expression { 577 | T_INCDEC unary_expression {
578 $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL); 578 $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL);
579 } 579 }
580 | T_AMPER cast_expression { 580 | T_AMPER cast_expression {
581 $$ = build(ADDR, $2, NULL); 581 $$ = build(ADDR, $2, NULL);
582 } 582 }
583 | T_ASTERISK cast_expression { 583 | T_ASTERISK cast_expression {
584 $$ = build(INDIR, $2, NULL); 584 $$ = build(INDIR, $2, NULL);
585 } 585 }
586 | T_ADDITIVE cast_expression { 586 | T_ADDITIVE cast_expression {
587 if (tflag && $1 == PLUS) { 587 if (tflag && $1 == PLUS) {
588 /* unary + is illegal in traditional C */ 588 /* unary + is illegal in traditional C */
589 warning(100); 589 warning(100);
590 } 590 }
591 $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL); 591 $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL);
592 } 592 }
593 | T_COMPLEMENT cast_expression { 593 | T_COMPLEMENT cast_expression {
594 $$ = build(COMPL, $2, NULL); 594 $$ = build(COMPL, $2, NULL);
595 } 595 }
596 | T_LOGNOT cast_expression { 596 | T_LOGNOT cast_expression {
597 $$ = build(NOT, $2, NULL); 597 $$ = build(NOT, $2, NULL);
598 } 598 }
599 | T_REAL cast_expression { /* GCC c_parser_unary_expression */ 599 | T_REAL cast_expression { /* GCC c_parser_unary_expression */
600 $$ = build(REAL, $2, NULL); 600 $$ = build(REAL, $2, NULL);
601 } 601 }
602 | T_IMAG cast_expression { /* GCC c_parser_unary_expression */ 602 | T_IMAG cast_expression { /* GCC c_parser_unary_expression */
603 $$ = build(IMAG, $2, NULL); 603 $$ = build(IMAG, $2, NULL);
604 } 604 }
605 | T_EXTENSION cast_expression { /* GCC c_parser_unary_expression */ 605 | T_EXTENSION cast_expression { /* GCC c_parser_unary_expression */
606 $$ = $2; 606 $$ = $2;
607 } 607 }
608 | T_SIZEOF unary_expression { 608 | T_SIZEOF unary_expression {
609 $$ = $2 == NULL ? NULL : build_sizeof($2->tn_type); 609 $$ = $2 == NULL ? NULL : build_sizeof($2->tn_type);
610 if ($$ != NULL) 610 if ($$ != NULL)
611 check_expr_misc($2, false, false, false, false, false, true); 611 check_expr_misc($2, false, false, false, false, false, true);
612 } 612 }
613 | T_SIZEOF T_LPAREN type_name T_RPAREN { 613 | T_SIZEOF T_LPAREN type_name T_RPAREN {
614 $$ = build_sizeof($3); 614 $$ = build_sizeof($3);
615 } 615 }
616 /* K&R ---, C90 ---, C99 ---, C11 6.5.3 */ 616 /* K&R ---, C90 ---, C99 ---, C11 6.5.3 */
617 | T_ALIGNOF T_LPAREN type_name T_RPAREN { 617 | T_ALIGNOF T_LPAREN type_name T_RPAREN {
618 $$ = build_alignof($3); 618 $$ = build_alignof($3);
619 } 619 }
620 ; 620 ;
621 621
622/* The rule 'unary_operator' is inlined into unary_expression. */ 622/* The rule 'unary_operator' is inlined into unary_expression. */
623 623
624/* K&R 7.2, C90 ???, C99 6.5.4, C11 6.5.4 */ 624/* K&R 7.2, C90 ???, C99 6.5.4, C11 6.5.4 */
625cast_expression: 625cast_expression:
626 unary_expression 626 unary_expression
627 | T_LPAREN type_name T_RPAREN cast_expression { 627 | T_LPAREN type_name T_RPAREN cast_expression {
628 $$ = cast($4, $2); 628 $$ = cast($4, $2);
629 } 629 }
630 ; 630 ;
631 631
632expression_opt: 632expression_opt:
633 /* empty */ { 633 /* empty */ {
634 $$ = NULL; 634 $$ = NULL;
635 } 635 }
636 | expression 636 | expression
637 ; 637 ;
638 638
639/* 'conditional_expression' also implements 'multiplicative_expression'. */ 639/* 'conditional_expression' also implements 'multiplicative_expression'. */
640/* 'conditional_expression' also implements 'additive_expression'. */ 640/* 'conditional_expression' also implements 'additive_expression'. */
641/* 'conditional_expression' also implements 'shift_expression'. */ 641/* 'conditional_expression' also implements 'shift_expression'. */
642/* 'conditional_expression' also implements 'relational_expression'. */ 642/* 'conditional_expression' also implements 'relational_expression'. */
643/* 'conditional_expression' also implements 'equality_expression'. */ 643/* 'conditional_expression' also implements 'equality_expression'. */
644/* 'conditional_expression' also implements 'AND_expression'. */ 644/* 'conditional_expression' also implements 'AND_expression'. */
645/* 'conditional_expression' also implements 'exclusive_OR_expression'. */ 645/* 'conditional_expression' also implements 'exclusive_OR_expression'. */
646/* 'conditional_expression' also implements 'inclusive_OR_expression'. */ 646/* 'conditional_expression' also implements 'inclusive_OR_expression'. */
647/* 'conditional_expression' also implements 'logical_AND_expression'. */ 647/* 'conditional_expression' also implements 'logical_AND_expression'. */
648/* 'conditional_expression' also implements 'logical_OR_expression'. */ 648/* 'conditional_expression' also implements 'logical_OR_expression'. */
649/* K&R ???, C90 ???, C99 6.5.5 to 6.5.15, C11 6.5.5 to 6.5.15 */ 649/* K&R ???, C90 ???, C99 6.5.5 to 6.5.15, C11 6.5.5 to 6.5.15 */
650conditional_expression: 650conditional_expression:
651 conditional_expression T_ASTERISK conditional_expression { 651 conditional_expression T_ASTERISK conditional_expression {
652 $$ = build(MULT, $1, $3); 652 $$ = build(MULT, $1, $3);
653 } 653 }
654 | conditional_expression T_MULTIPLICATIVE conditional_expression { 654 | conditional_expression T_MULTIPLICATIVE conditional_expression {
655 $$ = build($2, $1, $3); 655 $$ = build($2, $1, $3);
656 } 656 }
657 | conditional_expression T_ADDITIVE conditional_expression { 657 | conditional_expression T_ADDITIVE conditional_expression {
658 $$ = build($2, $1, $3); 658 $$ = build($2, $1, $3);
659 } 659 }
660 | conditional_expression T_SHIFT conditional_expression { 660 | conditional_expression T_SHIFT conditional_expression {
661 $$ = build($2, $1, $3); 661 $$ = build($2, $1, $3);
662 } 662 }
663 | conditional_expression T_RELATIONAL conditional_expression { 663 | conditional_expression T_RELATIONAL conditional_expression {
664 $$ = build($2, $1, $3); 664 $$ = build($2, $1, $3);
665 } 665 }
666 | conditional_expression T_EQUALITY conditional_expression { 666 | conditional_expression T_EQUALITY conditional_expression {
667 $$ = build($2, $1, $3); 667 $$ = build($2, $1, $3);
668 } 668 }
669 | conditional_expression T_AMPER conditional_expression { 669 | conditional_expression T_AMPER conditional_expression {
670 $$ = build(BITAND, $1, $3); 670 $$ = build(BITAND, $1, $3);
671 } 671 }
672 | conditional_expression T_BITXOR conditional_expression { 672 | conditional_expression T_BITXOR conditional_expression {
673 $$ = build(BITXOR, $1, $3); 673 $$ = build(BITXOR, $1, $3);
674 } 674 }
675 | conditional_expression T_BITOR conditional_expression { 675 | conditional_expression T_BITOR conditional_expression {
676 $$ = build(BITOR, $1, $3); 676 $$ = build(BITOR, $1, $3);
677 } 677 }
678 | conditional_expression T_LOGAND conditional_expression { 678 | conditional_expression T_LOGAND conditional_expression {
679 $$ = build(LOGAND, $1, $3); 679 $$ = build(LOGAND, $1, $3);
680 } 680 }
681 | conditional_expression T_LOGOR conditional_expression { 681 | conditional_expression T_LOGOR conditional_expression {
682 $$ = build(LOGOR, $1, $3); 682 $$ = build(LOGOR, $1, $3);
683 } 683 }
684 | conditional_expression T_QUEST conditional_expression 684 | conditional_expression T_QUEST conditional_expression
685 T_COLON conditional_expression { 685 T_COLON conditional_expression {
686 $$ = build(QUEST, $1, build(COLON, $3, $5)); 686 $$ = build(QUEST, $1, build(COLON, $3, $5));
687 } 687 }
688 | cast_expression; 688 | cast_expression;
689 689
690/* K&R ???, C90 ???, C99 6.5.16, C11 6.5.16 */ 690/* K&R ???, C90 ???, C99 6.5.16, C11 6.5.16 */
691assignment_expression: 691assignment_expression:
692 conditional_expression 692 conditional_expression
693 | assignment_expression T_ASSIGN conditional_expression { 693 | assignment_expression T_ASSIGN conditional_expression {
694 $$ = build(ASSIGN, $1, $3); 694 $$ = build(ASSIGN, $1, $3);
695 } 695 }
696 | assignment_expression T_OPASSIGN conditional_expression { 696 | assignment_expression T_OPASSIGN conditional_expression {
697 $$ = build($2, $1, $3); 697 $$ = build($2, $1, $3);
698 } 698 }
699 ; 699 ;
700 700
701/* K&R ???, C90 ???, C99 6.5.17, C11 6.5.17 */ 701/* K&R ???, C90 ???, C99 6.5.17, C11 6.5.17 */
702expression: 702expression:
703 assignment_expression 703 assignment_expression
704 | expression T_COMMA assignment_expression { 704 | expression T_COMMA assignment_expression {
705 $$ = build(COMMA, $1, $3); 705 $$ = build(COMMA, $1, $3);
706 } 706 }
707 ; 707 ;
708 708
709constant_expr_list_opt: /* helper for gcc_attribute */ 709constant_expr_list_opt: /* helper for gcc_attribute */
710 /* empty */ 710 /* empty */
711 | constant_expr_list 711 | constant_expr_list
712 ; 712 ;
713 713
714constant_expr_list: /* helper for gcc_attribute */ 714constant_expr_list: /* helper for gcc_attribute */
715 constant_expr 715 constant_expr
716 | constant_expr_list T_COMMA constant_expr 716 | constant_expr_list T_COMMA constant_expr
717 ; 717 ;
718 718
719constant_expr: /* C99 6.6 */ 719constant_expr: /* C99 6.6 */
720 conditional_expression 720 conditional_expression
721 ; 721 ;
722 722
723declaration_or_error: 723declaration_or_error:
724 declaration 724 declaration
725 | error T_SEMI 725 | error T_SEMI
726 ; 726 ;
727 727
728declaration: /* C99 6.7 */ 728declaration: /* C99 6.7 */
729 begin_type_declmods end_type T_SEMI { 729 begin_type_declmods end_type T_SEMI {
730 if (dcs->d_scl == TYPEDEF) { 730 if (dcs->d_scl == TYPEDEF) {
731 /* typedef declares no type name */ 731 /* typedef declares no type name */
732 warning(72); 732 warning(72);
733 } else { 733 } else {
734 /* empty declaration */ 734 /* empty declaration */
735 warning(2); 735 warning(2);
736 } 736 }
737 } 737 }
738 | begin_type_declmods end_type notype_init_declarators T_SEMI 738 | begin_type_declmods end_type notype_init_declarators T_SEMI
739 | begin_type_declaration_specifiers end_type T_SEMI { 739 | begin_type_declaration_specifiers end_type T_SEMI {
740 if (dcs->d_scl == TYPEDEF) { 740 if (dcs->d_scl == TYPEDEF) {
741 /* typedef declares no type name */ 741 /* typedef declares no type name */
742 warning(72); 742 warning(72);
743 } else if (!dcs->d_nonempty_decl) { 743 } else if (!dcs->d_nonempty_decl) {
744 /* empty declaration */ 744 /* empty declaration */
745 warning(2); 745 warning(2);
746 } 746 }
747 } 747 }
748 | begin_type_declaration_specifiers end_type 748 | begin_type_declaration_specifiers end_type
749 type_init_declarators T_SEMI 749 type_init_declarators T_SEMI
750 ; 750 ;
751 751
752begin_type_declaration_specifiers: /* see C99 6.7 */ 752begin_type_declaration_specifiers: /* see C99 6.7 */
753 begin_type_typespec { 753 begin_type_typespec {
754 add_type($1); 754 add_type($1);
755 } 755 }
756 | begin_type_declmods type_specifier { 756 | begin_type_declmods type_specifier {
757 add_type($2); 757 add_type($2);
758 } 758 }
759 | type_attribute begin_type_declaration_specifiers 759 | type_attribute begin_type_declaration_specifiers
760 | begin_type_declaration_specifiers declmod 760 | begin_type_declaration_specifiers declmod
761 | begin_type_declaration_specifiers notype_type_specifier { 761 | begin_type_declaration_specifiers notype_type_specifier {
762 add_type($2); 762 add_type($2);
763 } 763 }
764 ; 764 ;
765 765
766begin_type_declmods: /* see C99 6.7 */ 766begin_type_declmods: /* see C99 6.7 */
767 begin_type T_QUAL { 767 begin_type T_QUAL {
768 add_qualifier($2); 768 add_qualifier($2);
769 } 769 }
770 | begin_type T_SCLASS { 770 | begin_type T_SCLASS {
771 add_storage_class($2); 771 add_storage_class($2);
772 } 772 }
773 | begin_type_declmods declmod 773 | begin_type_declmods declmod
774 ; 774 ;
775 775
776begin_type_noclass_declspecs: 776begin_type_noclass_declspecs:
777 begin_type_typespec { 777 begin_type_typespec {
778 add_type($1); 778 add_type($1);
779 } 779 }
780 | type_attribute begin_type_noclass_declspecs 780 | type_attribute begin_type_noclass_declspecs
781 | begin_type_noclass_declmods type_specifier { 781 | begin_type_noclass_declmods type_specifier {
782 add_type($2); 782 add_type($2);
783 } 783 }
784 | begin_type_noclass_declspecs T_QUAL { 784 | begin_type_noclass_declspecs T_QUAL {
785 add_qualifier($2); 785 add_qualifier($2);
786 } 786 }
787 | begin_type_noclass_declspecs notype_type_specifier { 787 | begin_type_noclass_declspecs notype_type_specifier {
788 add_type($2); 788 add_type($2);
789 } 789 }
790 | begin_type_noclass_declspecs type_attribute 790 | begin_type_noclass_declspecs type_attribute
791 ; 791 ;
792 792
793begin_type_typespec: 793begin_type_typespec:
794 begin_type notype_type_specifier { 794 begin_type notype_type_specifier {
795 $$ = $2; 795 $$ = $2;
796 } 796 }
797 | T_TYPENAME begin_type { 797 | T_TYPENAME begin_type {
798 $$ = getsym($1)->s_type; 798 $$ = getsym($1)->s_type;
799 } 799 }
800 ; 800 ;
801 801
802begin_type_noclass_declmods: 802begin_type_noclass_declmods:
803 begin_type T_QUAL { 803 begin_type T_QUAL {
804 add_qualifier($2); 804 add_qualifier($2);
805 } 805 }
806 | begin_type_noclass_declmods T_QUAL { 806 | begin_type_noclass_declmods T_QUAL {
807 add_qualifier($2); 807 add_qualifier($2);
808 } 808 }
809 ; 809 ;
810 810
811declmod: 811declmod:
812 T_QUAL { 812 T_QUAL {
813 add_qualifier($1); 813 add_qualifier($1);
814 } 814 }
815 | T_SCLASS { 815 | T_SCLASS {
816 add_storage_class($1); 816 add_storage_class($1);
817 } 817 }
818 | type_attribute_list 818 | type_attribute_list
819 ; 819 ;
820 820
821type_attribute_list: 821type_attribute_list:
822 type_attribute 822 type_attribute
823 | type_attribute_list type_attribute 823 | type_attribute_list type_attribute
824 ; 824 ;
825 825
826type_attribute_opt: 826type_attribute_opt:
827 /* empty */ 827 /* empty */
828 | type_attribute 828 | type_attribute
829 ; 829 ;
830 830
831type_attribute: /* See C11 6.7 declaration-specifiers */ 831type_attribute: /* See C11 6.7 declaration-specifiers */
832 T_ATTRIBUTE T_LPAREN T_LPAREN { 832 T_ATTRIBUTE T_LPAREN T_LPAREN {
833 attron = true; 833 attron = true;
834 } gcc_attribute_spec_list { 834 } gcc_attribute_spec_list {
835 attron = false; 835 attron = false;
836 } T_RPAREN T_RPAREN 836 } T_RPAREN T_RPAREN
837 | T_ALIGNAS T_LPAREN align_as T_RPAREN 837 | T_ALIGNAS T_LPAREN align_as T_RPAREN
838 | T_PACKED { 838 | T_PACKED {
839 addpacked(); 839 addpacked();
840 } 840 }
841 | T_NORETURN 841 | T_NORETURN
842 ; 842 ;
843 843
844align_as: /* See alignment-specifier in C11 6.7.5 */ 844align_as: /* See alignment-specifier in C11 6.7.5 */
845 type_specifier 845 type_specifier
846 | constant_expr 846 | constant_expr
847 ; 847 ;
848 848
849begin_type: 849begin_type:
850 /* empty */ { 850 /* empty */ {
851 begin_type(); 851 begin_type();
852 } 852 }
853 ; 853 ;
854 854
855end_type: 855end_type:
856 /* empty */ { 856 /* empty */ {
857 end_type(); 857 end_type();
858 } 858 }
859 ; 859 ;
860 860
861type_specifier: /* C99 6.7.2 */ 861type_specifier: /* C99 6.7.2 */
862 notype_type_specifier 862 notype_type_specifier
863 | T_TYPENAME { 863 | T_TYPENAME {
864 $$ = getsym($1)->s_type; 864 $$ = getsym($1)->s_type;
865 } 865 }
866 ; 866 ;
867 867
868notype_type_specifier: /* see C99 6.7.2 */ 868notype_type_specifier: /* see C99 6.7.2 */
869 T_TYPE { 869 T_TYPE {
870 $$ = gettyp($1); 870 $$ = gettyp($1);
871 } 871 }
872 | T_TYPEOF cast_expression { /* GCC extension */ 872 | T_TYPEOF cast_expression { /* GCC extension */
873 $$ = $2->tn_type; 873 $$ = $2->tn_type;
874 } 874 }
875 | struct_or_union_specifier { 875 | struct_or_union_specifier {
876 end_declaration_level(); 876 end_declaration_level();
877 $$ = $1; 877 $$ = $1;
878 } 878 }
879 | enum_specifier { 879 | enum_specifier {
880 end_declaration_level(); 880 end_declaration_level();
881 $$ = $1; 881 $$ = $1;
882 } 882 }
883 ; 883 ;
884 884
885struct_or_union_specifier: /* C99 6.7.2.1 */ 885struct_or_union_specifier: /* C99 6.7.2.1 */
886 struct_or_union identifier_sym { 886 struct_or_union identifier_sym {
887 /* 887 /*
888 * STDC requires that "struct a;" always introduces 888 * STDC requires that "struct a;" always introduces
889 * a new tag if "a" is not declared at current level 889 * a new tag if "a" is not declared at current level
890 * 890 *
891 * yychar is valid because otherwise the parser would not 891 * yychar is valid because otherwise the parser would not
892 * have been able to decide if it must shift or reduce 892 * have been able to decide if it must shift or reduce
893 */ 893 */
894 $$ = mktag($2, $1, false, yychar == T_SEMI); 894 $$ = mktag($2, $1, false, yychar == T_SEMI);
895 } 895 }
896 | struct_or_union identifier_sym { 896 | struct_or_union identifier_sym {
897 dcs->d_tagtyp = mktag($2, $1, true, false); 897 dcs->d_tagtyp = mktag($2, $1, true, false);
898 } braced_struct_declaration_list { 898 } braced_struct_declaration_list {
899 $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4); 899 $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4);
900 } 900 }
901 | struct_or_union { 901 | struct_or_union {
902 dcs->d_tagtyp = mktag(NULL, $1, true, false); 902 dcs->d_tagtyp = mktag(NULL, $1, true, false);
903 } braced_struct_declaration_list { 903 } braced_struct_declaration_list {
904 $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3); 904 $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3);
905 } 905 }
906 | struct_or_union error { 906 | struct_or_union error {
907 symtyp = FVFT; 907 symtyp = FVFT;
908 $$ = gettyp(INT); 908 $$ = gettyp(INT);
909 } 909 }
910 ; 910 ;
911 911
912struct_or_union: /* C99 6.7.2.1 */ 912struct_or_union: /* C99 6.7.2.1 */
913 struct_or_union type_attribute 913 struct_or_union type_attribute
914 | T_STRUCT_OR_UNION { 914 | T_STRUCT_OR_UNION {
915 symtyp = FTAG; 915 symtyp = FTAG;
916 begin_declaration_level($1 == STRUCT ? MOS : MOU); 916 begin_declaration_level($1 == STRUCT ? MOS : MOU);
917 dcs->d_offset = 0; 917 dcs->d_offset = 0;
918 dcs->d_sou_align_in_bits = CHAR_SIZE; 918 dcs->d_sou_align_in_bits = CHAR_SIZE;
919 $$ = $1; 919 $$ = $1;
920 } 920 }
921 ; 921 ;
922 922
923braced_struct_declaration_list: /* see C99 6.7.2.1 */ 923braced_struct_declaration_list: /* see C99 6.7.2.1 */
924 struct_declaration_lbrace struct_declaration_list_with_rbrace { 924 struct_declaration_lbrace struct_declaration_list_with_rbrace {
925 $$ = $2; 925 $$ = $2;
926 } 926 }
927 ; 927 ;
928 928
929struct_declaration_lbrace: /* see C99 6.7.2.1 */ 929struct_declaration_lbrace: /* see C99 6.7.2.1 */
930 T_LBRACE { 930 T_LBRACE {
931 symtyp = FVFT; 931 symtyp = FVFT;
932 } 932 }
933 ; 933 ;
934 934
935struct_declaration_list_with_rbrace: /* see C99 6.7.2.1 */ 935struct_declaration_list_with_rbrace: /* see C99 6.7.2.1 */
936 struct_declaration_list T_SEMI T_RBRACE 936 struct_declaration_list T_RBRACE
937 | struct_declaration_list T_RBRACE { 
938 if (sflag) { 
939 /* syntax req. ';' after last struct/union member */ 
940 error(66); 
941 } else { 
942 /* syntax req. ';' after last struct/union member */ 
943 warning(66); 
944 } 
945 $$ = $1; 
946 } 
947 | T_RBRACE { 937 | T_RBRACE {
 938 /* XXX: This is not allowed by any C standard. */
948 $$ = NULL; 939 $$ = NULL;
949 } 940 }
950 ; 941 ;
951 942
952struct_declaration_list: /* C99 6.7.2.1 */ 943struct_declaration_list: /* C99 6.7.2.1 */
953 struct_declaration 944 struct_declaration
954 | struct_declaration_list T_SEMI struct_declaration { 945 | struct_declaration_list struct_declaration {
955 $$ = lnklst($1, $3); 946 $$ = lnklst($1, $2);
956 } 947 }
957 ; 948 ;
958 949
959struct_declaration: /* C99 6.7.2.1 */ 950struct_declaration: /* C99 6.7.2.1 */
960 begin_type_noclass_declmods end_type { 951 begin_type_noclass_declmods end_type {
961 /* too late, i know, but getsym() compensates it */ 952 /* too late, i know, but getsym() compensates it */
962 symtyp = FMEMBER; 953 symtyp = FMEMBER;
963 } notype_struct_declarators type_attribute_opt { 954 } notype_struct_declarators type_attribute_opt T_SEMI {
964 symtyp = FVFT; 955 symtyp = FVFT;
965 $$ = $4; 956 $$ = $4;
966 } 957 }
967 | begin_type_noclass_declspecs end_type { 958 | begin_type_noclass_declspecs end_type {
968 symtyp = FMEMBER; 959 symtyp = FMEMBER;
969 } type_struct_declarators type_attribute_opt { 960 } type_struct_declarators type_attribute_opt T_SEMI {
970 symtyp = FVFT; 961 symtyp = FVFT;
971 $$ = $4; 962 $$ = $4;
972 } 963 }
973 | begin_type_noclass_declmods end_type type_attribute_opt { 964 | begin_type_noclass_declmods end_type type_attribute_opt T_SEMI {
974 /* syntax error '%s' */ 965 /* syntax error '%s' */
975 error(249, "member without type"); 966 error(249, "member without type");
976 $$ = NULL; 967 $$ = NULL;
977 } 968 }
978 | begin_type_noclass_declspecs end_type type_attribute_opt { 969 | begin_type_noclass_declspecs end_type type_attribute_opt T_SEMI {
979 symtyp = FVFT; 970 symtyp = FVFT;
980 if (!Sflag) 971 if (!Sflag)
981 /* anonymous struct/union members is a C9X feature */ 972 /* anonymous struct/union members is a C9X feature */
982 warning(49); 973 warning(49);
983 if (is_struct_or_union(dcs->d_type->t_tspec)) { 974 if (is_struct_or_union(dcs->d_type->t_tspec)) {
984 $$ = dcs->d_type->t_str->sou_first_member; 975 $$ = dcs->d_type->t_str->sou_first_member;
985 /* add all the members of the anonymous struct/union */ 976 /* add all the members of the anonymous struct/union */
986 anonymize($$); 977 anonymize($$);
987 } else { 978 } else {
988 /* syntax error '%s' */ 979 /* syntax error '%s' */
989 error(249, "unnamed member"); 980 error(249, "unnamed member");
990 $$ = NULL; 981 $$ = NULL;
991 } 982 }
992 } 983 }
993 | error { 984 | error T_SEMI {
994 symtyp = FVFT; 985 symtyp = FVFT;
995 $$ = NULL; 986 $$ = NULL;
996 } 987 }
997 ; 988 ;
998 989
999notype_struct_declarators: 990notype_struct_declarators:
1000 notype_struct_declarator { 991 notype_struct_declarator {
1001 $$ = declarator_1_struct_union($1); 992 $$ = declarator_1_struct_union($1);
1002 } 993 }
1003 | notype_struct_declarators { 994 | notype_struct_declarators {
1004 symtyp = FMEMBER; 995 symtyp = FMEMBER;
1005 } T_COMMA type_struct_declarator { 996 } T_COMMA type_struct_declarator {
1006 $$ = lnklst($1, declarator_1_struct_union($4)); 997 $$ = lnklst($1, declarator_1_struct_union($4));
1007 } 998 }
1008 ; 999 ;
1009 1000
1010type_struct_declarators: 1001type_struct_declarators:
1011 type_struct_declarator { 1002 type_struct_declarator {
1012 $$ = declarator_1_struct_union($1); 1003 $$ = declarator_1_struct_union($1);
1013 } 1004 }
1014 | type_struct_declarators { 1005 | type_struct_declarators {
1015 symtyp = FMEMBER; 1006 symtyp = FMEMBER;
1016 } T_COMMA type_struct_declarator { 1007 } T_COMMA type_struct_declarator {
1017 $$ = lnklst($1, declarator_1_struct_union($4)); 1008 $$ = lnklst($1, declarator_1_struct_union($4));
1018 } 1009 }
1019 ; 1010 ;
1020 1011
1021notype_struct_declarator: 1012notype_struct_declarator:
1022 notype_declarator 1013 notype_declarator
1023 | notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */ 1014 | notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */
1024 $$ = bitfield($1, to_int_constant($3, true)); 1015 $$ = bitfield($1, to_int_constant($3, true));
1025 } 1016 }
1026 | { 1017 | {
1027 symtyp = FVFT; 1018 symtyp = FVFT;
1028 } T_COLON constant_expr { /* C99 6.7.2.1 */ 1019 } T_COLON constant_expr { /* C99 6.7.2.1 */
1029 $$ = bitfield(NULL, to_int_constant($3, true)); 1020 $$ = bitfield(NULL, to_int_constant($3, true));
1030 } 1021 }
1031 ; 1022 ;
1032 1023
1033type_struct_declarator: 1024type_struct_declarator:
1034 type_declarator 1025 type_declarator
1035 | type_declarator T_COLON constant_expr { 1026 | type_declarator T_COLON constant_expr {
1036 $$ = bitfield($1, to_int_constant($3, true)); 1027 $$ = bitfield($1, to_int_constant($3, true));
1037 } 1028 }
1038 | { 1029 | {
1039 symtyp = FVFT; 1030 symtyp = FVFT;
1040 } T_COLON constant_expr { 1031 } T_COLON constant_expr {
1041 $$ = bitfield(NULL, to_int_constant($3, true)); 1032 $$ = bitfield(NULL, to_int_constant($3, true));
1042 } 1033 }
1043 ; 1034 ;
1044 1035
1045enum_specifier: /* C99 6.7.2.2 */ 1036enum_specifier: /* C99 6.7.2.2 */
1046 enum identifier_sym { 1037 enum identifier_sym {
1047 $$ = mktag($2, ENUM, false, false); 1038 $$ = mktag($2, ENUM, false, false);
1048 } 1039 }
1049 | enum identifier_sym { 1040 | enum identifier_sym {
1050 dcs->d_tagtyp = mktag($2, ENUM, true, false); 1041 dcs->d_tagtyp = mktag($2, ENUM, true, false);
1051 } enum_declaration { 1042 } enum_declaration {
1052 $$ = complete_tag_enum(dcs->d_tagtyp, $4); 1043 $$ = complete_tag_enum(dcs->d_tagtyp, $4);
1053 } 1044 }
1054 | enum { 1045 | enum {
1055 dcs->d_tagtyp = mktag(NULL, ENUM, true, false); 1046 dcs->d_tagtyp = mktag(NULL, ENUM, true, false);
1056 } enum_declaration { 1047 } enum_declaration {
1057 $$ = complete_tag_enum(dcs->d_tagtyp, $3); 1048 $$ = complete_tag_enum(dcs->d_tagtyp, $3);
1058 } 1049 }
1059 | enum error { 1050 | enum error {
1060 symtyp = FVFT; 1051 symtyp = FVFT;
1061 $$ = gettyp(INT); 1052 $$ = gettyp(INT);
1062 } 1053 }
1063 ; 1054 ;
1064 1055
1065enum: /* helper for C99 6.7.2.2 */ 1056enum: /* helper for C99 6.7.2.2 */
1066 T_ENUM { 1057 T_ENUM {
1067 symtyp = FTAG; 1058 symtyp = FTAG;
1068 begin_declaration_level(CTCONST); 1059 begin_declaration_level(CTCONST);
1069 } 1060 }
1070 ; 1061 ;
1071 1062
1072enum_declaration: /* helper for C99 6.7.2.2 */ 1063enum_declaration: /* helper for C99 6.7.2.2 */
1073 enum_decl_lbrace enums_with_opt_comma T_RBRACE { 1064 enum_decl_lbrace enums_with_opt_comma T_RBRACE {
1074 $$ = $2; 1065 $$ = $2;
1075 } 1066 }
1076 ; 1067 ;
1077 1068
1078enum_decl_lbrace: /* helper for C99 6.7.2.2 */ 1069enum_decl_lbrace: /* helper for C99 6.7.2.2 */
1079 T_LBRACE { 1070 T_LBRACE {
1080 symtyp = FVFT; 1071 symtyp = FVFT;
1081 enumval = 0; 1072 enumval = 0;
1082 } 1073 }
1083 ; 1074 ;
1084 1075
1085enums_with_opt_comma: /* helper for C99 6.7.2.2 */ 1076enums_with_opt_comma: /* helper for C99 6.7.2.2 */
1086 enumerator_list 1077 enumerator_list
1087 | enumerator_list T_COMMA { 1078 | enumerator_list T_COMMA {
1088 if (sflag) { 1079 if (sflag) {
1089 /* trailing ',' prohibited in enum declaration */ 1080 /* trailing ',' prohibited in enum declaration */
1090 error(54); 1081 error(54);
1091 } else { 1082 } else {
1092 /* trailing ',' prohibited in enum declaration */ 1083 /* trailing ',' prohibited in enum declaration */
1093 c99ism(54); 1084 c99ism(54);
1094 } 1085 }
1095 $$ = $1; 1086 $$ = $1;
1096 } 1087 }
1097 ; 1088 ;
1098 1089
1099enumerator_list: /* C99 6.7.2.2 */ 1090enumerator_list: /* C99 6.7.2.2 */
1100 enumerator 1091 enumerator
1101 | enumerator_list T_COMMA enumerator { 1092 | enumerator_list T_COMMA enumerator {
1102 $$ = lnklst($1, $3); 1093 $$ = lnklst($1, $3);
1103 } 1094 }
1104 | error { 1095 | error {
1105 $$ = NULL; 1096 $$ = NULL;
1106 } 1097 }
1107 ; 1098 ;
1108 1099
1109enumerator: /* C99 6.7.2.2 */ 1100enumerator: /* C99 6.7.2.2 */
1110 identifier_sym { 1101 identifier_sym {
1111 $$ = enumeration_constant($1, enumval, true); 1102 $$ = enumeration_constant($1, enumval, true);
1112 } 1103 }
1113 | identifier_sym T_ASSIGN constant_expr { 1104 | identifier_sym T_ASSIGN constant_expr {
1114 $$ = enumeration_constant($1, to_int_constant($3, true), false); 1105 $$ = enumeration_constant($1, to_int_constant($3, true), false);
1115 } 1106 }
1116 ; 1107 ;
1117 1108
1118type_qualifier: /* C99 6.7.3 */ 1109type_qualifier: /* C99 6.7.3 */
1119 T_QUAL { 1110 T_QUAL {
1120 $$ = xcalloc(1, sizeof(*$$)); 1111 $$ = xcalloc(1, sizeof(*$$));
1121 if ($1 == CONST) { 1112 if ($1 == CONST) {
1122 $$->p_const = true; 1113 $$->p_const = true;
1123 } else if ($1 == VOLATILE) { 1114 } else if ($1 == VOLATILE) {
1124 $$->p_volatile = true; 1115 $$->p_volatile = true;
1125 } else { 1116 } else {
1126 lint_assert($1 == RESTRICT || $1 == THREAD); 1117 lint_assert($1 == RESTRICT || $1 == THREAD);
1127 } 1118 }
1128 } 1119 }
1129 ; 1120 ;
1130 1121
1131pointer: /* C99 6.7.5 */ 1122pointer: /* C99 6.7.5 */
1132 asterisk type_qualifier_list_opt { 1123 asterisk type_qualifier_list_opt {
1133 $$ = merge_qualified_pointer($1, $2); 1124 $$ = merge_qualified_pointer($1, $2);
1134 } 1125 }
1135 | asterisk type_qualifier_list_opt pointer { 1126 | asterisk type_qualifier_list_opt pointer {
1136 $$ = merge_qualified_pointer($1, $2); 1127 $$ = merge_qualified_pointer($1, $2);
1137 $$ = merge_qualified_pointer($$, $3); 1128 $$ = merge_qualified_pointer($$, $3);
1138 } 1129 }
1139 ; 1130 ;
1140 1131
1141asterisk: /* helper for 'pointer' */ 1132asterisk: /* helper for 'pointer' */
1142 T_ASTERISK { 1133 T_ASTERISK {
1143 $$ = xcalloc(1, sizeof(*$$)); 1134 $$ = xcalloc(1, sizeof(*$$));
1144 $$->p_pointer = true; 1135 $$->p_pointer = true;
1145 } 1136 }
1146 ; 1137 ;
1147 1138
1148type_qualifier_list_opt: /* see C99 6.7.5 */ 1139type_qualifier_list_opt: /* see C99 6.7.5 */
1149 /* empty */ { 1140 /* empty */ {
1150 $$ = NULL; 1141 $$ = NULL;
1151 } 1142 }
1152 | type_qualifier_list 1143 | type_qualifier_list
1153 ; 1144 ;
1154 1145
1155type_qualifier_list: /* C99 6.7.5 */ 1146type_qualifier_list: /* C99 6.7.5 */
1156 type_qualifier 1147 type_qualifier
1157 | type_qualifier_list type_qualifier { 1148 | type_qualifier_list type_qualifier {
1158 $$ = merge_qualified_pointer($1, $2); 1149 $$ = merge_qualified_pointer($1, $2);
1159 } 1150 }
1160 ; 1151 ;
1161 1152
1162/* 1153/*
1163 * For an explanation of 'notype' in the following rules, see the Bison 1154 * For an explanation of 'notype' in the following rules, see the Bison
1164 * manual, section 7.1 "Semantic Info in Token Kinds". 1155 * manual, section 7.1 "Semantic Info in Token Kinds".
1165 */ 1156 */
1166 1157
1167notype_init_declarators: 1158notype_init_declarators:
1168 notype_init_declarator 1159 notype_init_declarator
1169 | notype_init_declarators T_COMMA type_init_declarator 1160 | notype_init_declarators T_COMMA type_init_declarator
1170 ; 1161 ;
1171 1162
1172type_init_declarators: 1163type_init_declarators:
1173 type_init_declarator 1164 type_init_declarator
1174 | type_init_declarators T_COMMA type_init_declarator 1165 | type_init_declarators T_COMMA type_init_declarator
1175 ; 1166 ;
1176 1167
1177notype_init_declarator: 1168notype_init_declarator:
1178 notype_declarator asm_or_symbolrename_opt { 1169 notype_declarator asm_or_symbolrename_opt {
1179 cgram_declare($1, false, $2); 1170 cgram_declare($1, false, $2);
1180 check_size($1); 1171 check_size($1);
1181 } 1172 }
1182 | notype_declarator asm_or_symbolrename_opt { 1173 | notype_declarator asm_or_symbolrename_opt {
1183 begin_initialization($1); 1174 begin_initialization($1);
1184 cgram_declare($1, true, $2); 1175 cgram_declare($1, true, $2);
1185 } T_ASSIGN initializer { 1176 } T_ASSIGN initializer {
1186 check_size($1); 1177 check_size($1);
1187 end_initialization(); 1178 end_initialization();
1188 } 1179 }
1189 ; 1180 ;
1190 1181
1191type_init_declarator: 1182type_init_declarator:
1192 type_declarator asm_or_symbolrename_opt { 1183 type_declarator asm_or_symbolrename_opt {
1193 cgram_declare($1, false, $2); 1184 cgram_declare($1, false, $2);
1194 check_size($1); 1185 check_size($1);
1195 } 1186 }
1196 | type_declarator asm_or_symbolrename_opt { 1187 | type_declarator asm_or_symbolrename_opt {
1197 begin_initialization($1); 1188 begin_initialization($1);
1198 cgram_declare($1, true, $2); 1189 cgram_declare($1, true, $2);
1199 } T_ASSIGN initializer { 1190 } T_ASSIGN initializer {
1200 check_size($1); 1191 check_size($1);
1201 end_initialization(); 1192 end_initialization();
1202 } 1193 }
1203 ; 1194 ;
1204 1195
1205notype_declarator: 1196notype_declarator:
1206 notype_direct_declarator 1197 notype_direct_declarator
1207 | pointer notype_direct_declarator { 1198 | pointer notype_direct_declarator {
1208 $$ = add_pointer($2, $1); 1199 $$ = add_pointer($2, $1);
1209 } 1200 }
1210 ; 1201 ;
1211 1202
1212type_declarator: 1203type_declarator:
1213 type_direct_declarator 1204 type_direct_declarator
1214 | pointer type_direct_declarator { 1205 | pointer type_direct_declarator {
1215 $$ = add_pointer($2, $1); 1206 $$ = add_pointer($2, $1);
1216 } 1207 }
1217 ; 1208 ;
1218 1209
1219notype_direct_declarator: 1210notype_direct_declarator:
1220 T_NAME { 1211 T_NAME {
1221 $$ = declarator_name(getsym($1)); 1212 $$ = declarator_name(getsym($1));
1222 } 1213 }
1223 | T_LPAREN type_declarator T_RPAREN { 1214 | T_LPAREN type_declarator T_RPAREN {
1224 $$ = $2; 1215 $$ = $2;
1225 } 1216 }
1226 | type_attribute notype_direct_declarator { 1217 | type_attribute notype_direct_declarator {
1227 $$ = $2; 1218 $$ = $2;
1228 } 1219 }
1229 | notype_direct_declarator T_LBRACK T_RBRACK { 1220 | notype_direct_declarator T_LBRACK T_RBRACK {
1230 $$ = add_array($1, false, 0); 1221 $$ = add_array($1, false, 0);
1231 } 1222 }
1232 | notype_direct_declarator T_LBRACK array_size T_RBRACK { 1223 | notype_direct_declarator T_LBRACK array_size T_RBRACK {
1233 $$ = add_array($1, true, to_int_constant($3, false)); 1224 $$ = add_array($1, true, to_int_constant($3, false));
1234 } 1225 }
1235 | notype_direct_declarator param_list asm_or_symbolrename_opt { 1226 | notype_direct_declarator param_list asm_or_symbolrename_opt {
1236 $$ = add_function(symbolrename($1, $3), $2); 1227 $$ = add_function(symbolrename($1, $3), $2);
1237 end_declaration_level(); 1228 end_declaration_level();
1238 block_level--; 1229 block_level--;
1239 } 1230 }
1240 | notype_direct_declarator type_attribute 1231 | notype_direct_declarator type_attribute
1241 ; 1232 ;
1242 1233
1243type_direct_declarator: 1234type_direct_declarator:
1244 identifier { 1235 identifier {
1245 $$ = declarator_name(getsym($1)); 1236 $$ = declarator_name(getsym($1));
1246 } 1237 }
1247 | T_LPAREN type_declarator T_RPAREN { 1238 | T_LPAREN type_declarator T_RPAREN {
1248 $$ = $2; 1239 $$ = $2;
1249 } 1240 }
1250 | type_attribute type_direct_declarator { 1241 | type_attribute type_direct_declarator {
1251 $$ = $2; 1242 $$ = $2;
1252 } 1243 }
1253 | type_direct_declarator T_LBRACK T_RBRACK { 1244 | type_direct_declarator T_LBRACK T_RBRACK {
1254 $$ = add_array($1, false, 0); 1245 $$ = add_array($1, false, 0);
1255 } 1246 }
1256 | type_direct_declarator T_LBRACK array_size T_RBRACK { 1247 | type_direct_declarator T_LBRACK array_size T_RBRACK {
1257 $$ = add_array($1, true, to_int_constant($3, false)); 1248 $$ = add_array($1, true, to_int_constant($3, false));
1258 } 1249 }
1259 | type_direct_declarator param_list asm_or_symbolrename_opt { 1250 | type_direct_declarator param_list asm_or_symbolrename_opt {
1260 $$ = add_function(symbolrename($1, $3), $2); 1251 $$ = add_function(symbolrename($1, $3), $2);
1261 end_declaration_level(); 1252 end_declaration_level();
1262 block_level--; 1253 block_level--;
1263 } 1254 }
1264 | type_direct_declarator type_attribute 1255 | type_direct_declarator type_attribute
1265 ; 1256 ;
1266 1257
1267/* 1258/*
1268 * The two distinct rules type_param_declarator and notype_param_declarator avoid a 1259 * The two distinct rules type_param_declarator and notype_param_declarator avoid a
1269 * conflict in argument lists. A typename enclosed in parentheses is always 1260 * conflict in argument lists. A typename enclosed in parentheses is always
1270 * treated as a typename, not an argument name. For example, after 1261 * treated as a typename, not an argument name. For example, after
1271 * "typedef double a;", the declaration "f(int (a));" is interpreted as 1262 * "typedef double a;", the declaration "f(int (a));" is interpreted as
1272 * "f(int (double));", not "f(int a);". 1263 * "f(int (double));", not "f(int a);".
1273 */ 1264 */
1274type_param_declarator: 1265type_param_declarator:
1275 direct_param_declarator 1266 direct_param_declarator
1276 | pointer direct_param_declarator { 1267 | pointer direct_param_declarator {
1277 $$ = add_pointer($2, $1); 1268 $$ = add_pointer($2, $1);
1278 } 1269 }
1279 ; 1270 ;
1280 1271
1281notype_param_declarator: 1272notype_param_declarator:
1282 direct_notype_param_declarator 1273 direct_notype_param_declarator
1283 | pointer direct_notype_param_declarator { 1274 | pointer direct_notype_param_declarator {
1284 $$ = add_pointer($2, $1); 1275 $$ = add_pointer($2, $1);
1285 } 1276 }
1286 ; 1277 ;
1287 1278
1288direct_param_declarator: 1279direct_param_declarator:
1289 identifier type_attribute_list { 1280 identifier type_attribute_list {
1290 $$ = declarator_name(getsym($1)); 1281 $$ = declarator_name(getsym($1));
1291 } 1282 }
1292 | identifier { 1283 | identifier {
1293 $$ = declarator_name(getsym($1)); 1284 $$ = declarator_name(getsym($1));
1294 } 1285 }
1295 | T_LPAREN notype_param_declarator T_RPAREN { 1286 | T_LPAREN notype_param_declarator T_RPAREN {
1296 $$ = $2; 1287 $$ = $2;
1297 } 1288 }
1298 | direct_param_declarator T_LBRACK T_RBRACK { 1289 | direct_param_declarator T_LBRACK T_RBRACK {
1299 $$ = add_array($1, false, 0); 1290 $$ = add_array($1, false, 0);
1300 } 1291 }
1301 | direct_param_declarator T_LBRACK array_size T_RBRACK { 1292 | direct_param_declarator T_LBRACK array_size T_RBRACK {
1302 $$ = add_array($1, true, to_int_constant($3, false)); 1293 $$ = add_array($1, true, to_int_constant($3, false));
1303 } 1294 }
1304 | direct_param_declarator param_list asm_or_symbolrename_opt { 1295 | direct_param_declarator param_list asm_or_symbolrename_opt {
1305 $$ = add_function(symbolrename($1, $3), $2); 1296 $$ = add_function(symbolrename($1, $3), $2);
1306 end_declaration_level(); 1297 end_declaration_level();
1307 block_level--; 1298 block_level--;
1308 } 1299 }
1309 ; 1300 ;
1310 1301
1311direct_notype_param_declarator: 1302direct_notype_param_declarator:
1312 identifier { 1303 identifier {
1313 $$ = declarator_name(getsym($1)); 1304 $$ = declarator_name(getsym($1));
1314 } 1305 }
1315 | T_LPAREN notype_param_declarator T_RPAREN { 1306 | T_LPAREN notype_param_declarator T_RPAREN {
1316 $$ = $2; 1307 $$ = $2;
1317 } 1308 }
1318 | direct_notype_param_declarator T_LBRACK T_RBRACK { 1309 | direct_notype_param_declarator T_LBRACK T_RBRACK {
1319 $$ = add_array($1, false, 0); 1310 $$ = add_array($1, false, 0);
1320 } 1311 }
1321 | direct_notype_param_declarator T_LBRACK array_size T_RBRACK { 1312 | direct_notype_param_declarator T_LBRACK array_size T_RBRACK {
1322 $$ = add_array($1, true, to_int_constant($3, false)); 1313 $$ = add_array($1, true, to_int_constant($3, false));
1323 } 1314 }
1324 | direct_notype_param_declarator param_list asm_or_symbolrename_opt { 1315 | direct_notype_param_declarator param_list asm_or_symbolrename_opt {
1325 $$ = add_function(symbolrename($1, $3), $2); 1316 $$ = add_function(symbolrename($1, $3), $2);
1326 end_declaration_level(); 1317 end_declaration_level();
1327 block_level--; 1318 block_level--;
1328 } 1319 }
1329 ; 1320 ;
1330 1321
1331param_list: 1322param_list:
1332 id_list_lparen identifier_list T_RPAREN { 1323 id_list_lparen identifier_list T_RPAREN {
1333 $$ = $2; 1324 $$ = $2;
1334 } 1325 }
1335 | abstract_decl_param_list 1326 | abstract_decl_param_list
1336 ; 1327 ;
1337 1328
1338id_list_lparen: 1329id_list_lparen:
1339 T_LPAREN { 1330 T_LPAREN {
1340 block_level++; 1331 block_level++;
1341 begin_declaration_level(PROTO_ARG); 1332 begin_declaration_level(PROTO_ARG);
1342 } 1333 }
1343 ; 1334 ;
1344 1335
1345array_size: 1336array_size:
1346 type_qualifier_list_opt T_SCLASS constant_expr { 1337 type_qualifier_list_opt T_SCLASS constant_expr {
1347 /* C11 6.7.6.3p7 */ 1338 /* C11 6.7.6.3p7 */
1348 if ($2 != STATIC) 1339 if ($2 != STATIC)
1349 yyerror("Bad attribute"); 1340 yyerror("Bad attribute");
1350 /* static array size is a C11 extension */ 1341 /* static array size is a C11 extension */
1351 c11ism(343); 1342 c11ism(343);
1352 $$ = $3; 1343 $$ = $3;
1353 } 1344 }
1354 | constant_expr 1345 | constant_expr
1355 ; 1346 ;
1356 1347
1357identifier_list: /* C99 6.7.5 */ 1348identifier_list: /* C99 6.7.5 */
1358 T_NAME { 1349 T_NAME {
1359 $$ = old_style_function_name(getsym($1)); 1350 $$ = old_style_function_name(getsym($1));
1360 } 1351 }
1361 | identifier_list T_COMMA T_NAME { 1352 | identifier_list T_COMMA T_NAME {
1362 $$ = lnklst($1, old_style_function_name(getsym($3))); 1353 $$ = lnklst($1, old_style_function_name(getsym($3)));
1363 } 1354 }
1364 | identifier_list error 1355 | identifier_list error
1365 ; 1356 ;
1366 1357
1367/* XXX: C99 requires an additional specifier-qualifier-list. */ 1358/* XXX: C99 requires an additional specifier-qualifier-list. */
1368type_name: /* C99 6.7.6 */ 1359type_name: /* C99 6.7.6 */
1369 { 1360 {
1370 begin_declaration_level(ABSTRACT); 1361 begin_declaration_level(ABSTRACT);
1371 } abstract_declaration { 1362 } abstract_declaration {
1372 end_declaration_level(); 1363 end_declaration_level();
1373 $$ = $2->s_type; 1364 $$ = $2->s_type;
1374 } 1365 }
1375 ; 1366 ;
1376 1367
1377abstract_declaration: 1368abstract_declaration:
1378 begin_type_noclass_declmods end_type { 1369 begin_type_noclass_declmods end_type {
1379 $$ = declare_1_abstract(abstract_name()); 1370 $$ = declare_1_abstract(abstract_name());
1380 } 1371 }
1381 | begin_type_noclass_declspecs end_type { 1372 | begin_type_noclass_declspecs end_type {
1382 $$ = declare_1_abstract(abstract_name()); 1373 $$ = declare_1_abstract(abstract_name());
1383 } 1374 }
1384 | begin_type_noclass_declmods end_type abstract_declarator { 1375 | begin_type_noclass_declmods end_type abstract_declarator {
1385 $$ = declare_1_abstract($3); 1376 $$ = declare_1_abstract($3);
1386 } 1377 }
1387 | begin_type_noclass_declspecs end_type abstract_declarator { 1378 | begin_type_noclass_declspecs end_type abstract_declarator {
1388 $$ = declare_1_abstract($3); 1379 $$ = declare_1_abstract($3);
1389 } 1380 }
1390 ; 1381 ;
1391 1382
1392abstract_declarator: /* C99 6.7.6 */ 1383abstract_declarator: /* C99 6.7.6 */
1393 pointer { 1384 pointer {
1394 $$ = add_pointer(abstract_name(), $1); 1385 $$ = add_pointer(abstract_name(), $1);
1395 } 1386 }
1396 | direct_abstract_declarator 1387 | direct_abstract_declarator
1397 | pointer direct_abstract_declarator { 1388 | pointer direct_abstract_declarator {
1398 $$ = add_pointer($2, $1); 1389 $$ = add_pointer($2, $1);
1399 } 1390 }
1400 | T_TYPEOF cast_expression { /* GCC extension */ 1391 | T_TYPEOF cast_expression { /* GCC extension */
1401 $$ = mktempsym($2->tn_type); 1392 $$ = mktempsym($2->tn_type);
1402 } 1393 }
1403 ; 1394 ;
1404 1395
1405direct_abstract_declarator: /* C99 6.7.6 */ 1396direct_abstract_declarator: /* C99 6.7.6 */
1406 T_LPAREN abstract_declarator T_RPAREN { 1397 T_LPAREN abstract_declarator T_RPAREN {
1407 $$ = $2; 1398 $$ = $2;
1408 } 1399 }
1409 | T_LBRACK T_RBRACK { 1400 | T_LBRACK T_RBRACK {
1410 $$ = add_array(abstract_name(), false, 0); 1401 $$ = add_array(abstract_name(), false, 0);
1411 } 1402 }
1412 | T_LBRACK array_size T_RBRACK { 1403 | T_LBRACK array_size T_RBRACK {
1413 $$ = add_array(abstract_name(), true, to_int_constant($2, false)); 1404 $$ = add_array(abstract_name(), true, to_int_constant($2, false));
1414 } 1405 }
1415 | type_attribute direct_abstract_declarator { 1406 | type_attribute direct_abstract_declarator {
1416 $$ = $2; 1407 $$ = $2;
1417 } 1408 }
1418 | direct_abstract_declarator T_LBRACK T_RBRACK { 1409 | direct_abstract_declarator T_LBRACK T_RBRACK {
1419 $$ = add_array($1, false, 0); 1410 $$ = add_array($1, false, 0);
1420 } 1411 }
1421 | direct_abstract_declarator T_LBRACK T_ASTERISK T_RBRACK { /* C99 */ 1412 | direct_abstract_declarator T_LBRACK T_ASTERISK T_RBRACK { /* C99 */
1422 $$ = add_array($1, false, 0); 1413 $$ = add_array($1, false, 0);
1423 } 1414 }
1424 | direct_abstract_declarator T_LBRACK array_size T_RBRACK { 1415 | direct_abstract_declarator T_LBRACK array_size T_RBRACK {
1425 $$ = add_array($1, true, to_int_constant($3, false)); 1416 $$ = add_array($1, true, to_int_constant($3, false));
1426 } 1417 }
1427 | abstract_decl_param_list asm_or_symbolrename_opt { 1418 | abstract_decl_param_list asm_or_symbolrename_opt {
1428 $$ = add_function(symbolrename(abstract_name(), $2), $1); 1419 $$ = add_function(symbolrename(abstract_name(), $2), $1);
1429 end_declaration_level(); 1420 end_declaration_level();
1430 block_level--; 1421 block_level--;
1431 } 1422 }
1432 | direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt { 1423 | direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt {
1433 $$ = add_function(symbolrename($1, $3), $2); 1424 $$ = add_function(symbolrename($1, $3), $2);
1434 end_declaration_level(); 1425 end_declaration_level();
1435 block_level--; 1426 block_level--;
1436 } 1427 }
1437 | direct_abstract_declarator type_attribute_list 1428 | direct_abstract_declarator type_attribute_list
1438 ; 1429 ;
1439 1430
1440abstract_decl_param_list: 1431abstract_decl_param_list:
1441 abstract_decl_lparen T_RPAREN type_attribute_opt { 1432 abstract_decl_lparen T_RPAREN type_attribute_opt {
1442 $$ = NULL; 1433 $$ = NULL;
1443 } 1434 }
1444 | abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt { 1435 | abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt {
1445 dcs->d_proto = true; 1436 dcs->d_proto = true;
1446 $$ = $2; 1437 $$ = $2;
1447 } 1438 }
1448 | abstract_decl_lparen error T_RPAREN type_attribute_opt { 1439 | abstract_decl_lparen error T_RPAREN type_attribute_opt {
1449 $$ = NULL; 1440 $$ = NULL;
1450 } 1441 }
1451 ; 1442 ;
1452 1443
1453abstract_decl_lparen: 1444abstract_decl_lparen:
1454 T_LPAREN { 1445 T_LPAREN {
1455 block_level++; 1446 block_level++;
1456 begin_declaration_level(PROTO_ARG); 1447 begin_declaration_level(PROTO_ARG);
1457 } 1448 }
1458 ; 1449 ;
1459 1450
1460vararg_parameter_type_list: 1451vararg_parameter_type_list:
1461 parameter_type_list 1452 parameter_type_list
1462 | parameter_type_list T_COMMA T_ELLIPSIS { 1453 | parameter_type_list T_COMMA T_ELLIPSIS {
1463 dcs->d_vararg = true; 1454 dcs->d_vararg = true;
1464 $$ = $1; 1455 $$ = $1;
1465 } 1456 }
1466 | T_ELLIPSIS { 1457 | T_ELLIPSIS {
1467 if (sflag) { 1458 if (sflag) {
1468 /* ANSI C requires formal parameter before '...' */ 1459 /* ANSI C requires formal parameter before '...' */
1469 error(84); 1460 error(84);
1470 } else if (!tflag) { 1461 } else if (!tflag) {
1471 /* ANSI C requires formal parameter before '...' */ 1462 /* ANSI C requires formal parameter before '...' */
1472 warning(84); 1463 warning(84);
1473 } 1464 }
1474 dcs->d_vararg = true; 1465 dcs->d_vararg = true;
1475 $$ = NULL; 1466 $$ = NULL;
1476 } 1467 }
1477 ; 1468 ;
1478 1469
1479/* XXX: C99 6.7.5 defines the same name, but it looks different. */ 1470/* XXX: C99 6.7.5 defines the same name, but it looks different. */
1480parameter_type_list: 1471parameter_type_list:
1481 parameter_declaration 1472 parameter_declaration
1482 | parameter_type_list T_COMMA parameter_declaration { 1473 | parameter_type_list T_COMMA parameter_declaration {
1483 $$ = lnklst($1, $3); 1474 $$ = lnklst($1, $3);
1484 } 1475 }
1485 ; 1476 ;
1486 1477
1487/* XXX: C99 6.7.5 defines the same name, but it looks completely different. */ 1478/* XXX: C99 6.7.5 defines the same name, but it looks completely different. */
1488parameter_declaration: 1479parameter_declaration:
1489 begin_type_declmods end_type { 1480 begin_type_declmods end_type {
1490 $$ = declare_argument(abstract_name(), false); 1481 $$ = declare_argument(abstract_name(), false);
1491 } 1482 }
1492 | begin_type_declaration_specifiers end_type { 1483 | begin_type_declaration_specifiers end_type {
1493 $$ = declare_argument(abstract_name(), false); 1484 $$ = declare_argument(abstract_name(), false);
1494 } 1485 }
1495 | begin_type_declmods end_type notype_param_declarator { 1486 | begin_type_declmods end_type notype_param_declarator {
1496 $$ = declare_argument($3, false); 1487 $$ = declare_argument($3, false);
1497 } 1488 }
1498 /* 1489 /*
1499 * type_param_declarator is needed because of following conflict: 1490 * type_param_declarator is needed because of following conflict:
1500 * "typedef int a; f(int (a));" could be parsed as 1491 * "typedef int a; f(int (a));" could be parsed as
1501 * "function with argument a of type int", or 1492 * "function with argument a of type int", or
1502 * "function with an abstract argument of type function". 1493 * "function with an abstract argument of type function".
1503 * This grammar realizes the second case. 1494 * This grammar realizes the second case.
1504 */ 1495 */
1505 | begin_type_declaration_specifiers end_type type_param_declarator { 1496 | begin_type_declaration_specifiers end_type type_param_declarator {
1506 $$ = declare_argument($3, false); 1497 $$ = declare_argument($3, false);
1507 } 1498 }
1508 | begin_type_declmods end_type abstract_declarator { 1499 | begin_type_declmods end_type abstract_declarator {
1509 $$ = declare_argument($3, false); 1500 $$ = declare_argument($3, false);
1510 } 1501 }
1511 | begin_type_declaration_specifiers end_type abstract_declarator { 1502 | begin_type_declaration_specifiers end_type abstract_declarator {
1512 $$ = declare_argument($3, false); 1503 $$ = declare_argument($3, false);
1513 } 1504 }
1514 ; 1505 ;
1515 1506
1516initializer: /* C99 6.7.8 "Initialization" */ 1507initializer: /* C99 6.7.8 "Initialization" */
1517 assignment_expression { 1508 assignment_expression {
1518 init_expr($1); 1509 init_expr($1);
1519 } 1510 }
1520 | init_lbrace init_rbrace { 1511 | init_lbrace init_rbrace {
1521 /* XXX: Empty braces are not covered by C99 6.7.8. */ 1512 /* XXX: Empty braces are not covered by C99 6.7.8. */
1522 } 1513 }
1523 | init_lbrace initializer_list comma_opt init_rbrace 1514 | init_lbrace initializer_list comma_opt init_rbrace
1524 | error 1515 | error
1525 ; 1516 ;
1526 1517
1527initializer_list: /* C99 6.7.8 "Initialization" */ 1518initializer_list: /* C99 6.7.8 "Initialization" */
1528 initializer_list_item 1519 initializer_list_item
1529 | initializer_list T_COMMA initializer_list_item 1520 | initializer_list T_COMMA initializer_list_item
1530 ; 1521 ;
1531 1522
1532initializer_list_item: /* helper */ 1523initializer_list_item: /* helper */
1533 designation initializer 1524 designation initializer
1534 | initializer 1525 | initializer
1535 ; 1526 ;
1536 1527
1537designation: /* C99 6.7.8 "Initialization" */ 1528designation: /* C99 6.7.8 "Initialization" */
1538 designator_list T_ASSIGN 1529 designator_list T_ASSIGN
1539 | identifier T_COLON { 1530 | identifier T_COLON {
1540 /* GCC style struct or union member name in initializer */ 1531 /* GCC style struct or union member name in initializer */
1541 gnuism(315); 1532 gnuism(315);
1542 add_designator_member($1); 1533 add_designator_member($1);
1543 } 1534 }
1544 ; 1535 ;
1545 1536
1546designator_list: /* C99 6.7.8 "Initialization" */ 1537designator_list: /* C99 6.7.8 "Initialization" */
1547 designator 1538 designator
1548 | designator_list designator 1539 | designator_list designator
1549 ; 1540 ;
1550 1541
1551designator: /* C99 6.7.8 "Initialization" */ 1542designator: /* C99 6.7.8 "Initialization" */
1552 T_LBRACK range T_RBRACK { 1543 T_LBRACK range T_RBRACK {
1553 add_designator_subscript($2); 1544 add_designator_subscript($2);
1554 if (!Sflag) 1545 if (!Sflag)
1555 /* array initializer with des.s is a C9X feature */ 1546 /* array initializer with des.s is a C9X feature */
1556 warning(321); 1547 warning(321);
1557 } 1548 }
1558 | T_POINT identifier { 1549 | T_POINT identifier {
1559 if (!Sflag) 1550 if (!Sflag)
1560 /* struct or union member name in initializer is ... */ 1551 /* struct or union member name in initializer is ... */
1561 warning(313); 1552 warning(313);
1562 add_designator_member($2); 1553 add_designator_member($2);
1563 } 1554 }
1564 ; 1555 ;
1565 1556
1566range: 1557range:
1567 constant_expr { 1558 constant_expr {
1568 $$.lo = to_int_constant($1, true); 1559 $$.lo = to_int_constant($1, true);
1569 $$.hi = $$.lo; 1560 $$.hi = $$.lo;
1570 } 1561 }
1571 | constant_expr T_ELLIPSIS constant_expr { 1562 | constant_expr T_ELLIPSIS constant_expr {
1572 $$.lo = to_int_constant($1, true); 1563 $$.lo = to_int_constant($1, true);
1573 $$.hi = to_int_constant($3, true); 1564 $$.hi = to_int_constant($3, true);
1574 /* initialization with '[a...b]' is a GCC extension */ 1565 /* initialization with '[a...b]' is a GCC extension */
1575 gnuism(340); 1566 gnuism(340);
1576 } 1567 }
1577 ; 1568 ;
1578 1569
1579init_lbrace: /* helper */ 1570init_lbrace: /* helper */
1580 T_LBRACE { 1571 T_LBRACE {
1581 init_lbrace(); 1572 init_lbrace();
1582 } 1573 }
1583 ; 1574 ;
1584 1575
1585init_rbrace: /* helper */ 1576init_rbrace: /* helper */
1586 T_RBRACE { 1577 T_RBRACE {
1587 init_rbrace(); 1578 init_rbrace();
1588 } 1579 }
1589 ; 1580 ;
1590 1581
1591asm_or_symbolrename_opt: /* GCC extensions */ 1582asm_or_symbolrename_opt: /* GCC extensions */
1592 /* empty */ { 1583 /* empty */ {
1593 $$ = NULL; 1584 $$ = NULL;
1594 } 1585 }
1595 | T_ASM T_LPAREN T_STRING T_RPAREN { 1586 | T_ASM T_LPAREN T_STRING T_RPAREN {
1596 freeyyv(&$3, T_STRING); 1587 freeyyv(&$3, T_STRING);
1597 $$ = NULL; 1588 $$ = NULL;
1598 } 1589 }
1599 | T_SYMBOLRENAME T_LPAREN T_NAME T_RPAREN { 1590 | T_SYMBOLRENAME T_LPAREN T_NAME T_RPAREN {
1600 $$ = $3; 1591 $$ = $3;
1601 } 1592 }
1602 ; 1593 ;
1603 1594
1604statement: /* C99 6.8 */ 1595statement: /* C99 6.8 */
1605 expression_statement 1596 expression_statement
1606 | non_expr_statement 1597 | non_expr_statement
1607 ; 1598 ;
1608 1599
1609non_expr_statement: /* helper for C99 6.8 */ 1600non_expr_statement: /* helper for C99 6.8 */
1610 type_attribute T_SEMI 1601 type_attribute T_SEMI
1611 | labeled_statement 1602 | labeled_statement
1612 | compound_statement 1603 | compound_statement
1613 | selection_statement 1604 | selection_statement
1614 | iteration_statement 1605 | iteration_statement
1615 | jump_statement { 1606 | jump_statement {
1616 seen_fallthrough = false; 1607 seen_fallthrough = false;
1617 } 1608 }
1618 | asm_statement 1609 | asm_statement
1619 ; 1610 ;
1620 1611
1621labeled_statement: /* C99 6.8.1 */ 1612labeled_statement: /* C99 6.8.1 */
1622 label type_attribute_opt statement 1613 label type_attribute_opt statement
1623 ; 1614 ;
1624 1615
1625label: 1616label:
1626 T_NAME T_COLON { 1617 T_NAME T_COLON {
1627 symtyp = FLABEL; 1618 symtyp = FLABEL;
1628 named_label(getsym($1)); 1619 named_label(getsym($1));
1629 } 1620 }
1630 | T_CASE constant_expr T_COLON { 1621 | T_CASE constant_expr T_COLON {
1631 case_label($2); 1622 case_label($2);
1632 seen_fallthrough = true; 1623 seen_fallthrough = true;
1633 } 1624 }
1634 | T_CASE constant_expr T_ELLIPSIS constant_expr T_COLON { 1625 | T_CASE constant_expr T_ELLIPSIS constant_expr T_COLON {
1635 /* XXX: We don't fill all cases */ 1626 /* XXX: We don't fill all cases */
1636 case_label($2); 1627 case_label($2);
1637 seen_fallthrough = true; 1628 seen_fallthrough = true;
1638 } 1629 }
1639 | T_DEFAULT T_COLON { 1630 | T_DEFAULT T_COLON {
1640 default_label(); 1631 default_label();
1641 seen_fallthrough = true; 1632 seen_fallthrough = true;
1642 } 1633 }
1643 ; 1634 ;
1644 1635
1645compound_statement: /* C99 6.8.2 */ 1636compound_statement: /* C99 6.8.2 */
1646 compound_statement_lbrace compound_statement_rbrace 1637 compound_statement_lbrace compound_statement_rbrace
1647 | compound_statement_lbrace block_item_list compound_statement_rbrace 1638 | compound_statement_lbrace block_item_list compound_statement_rbrace
1648 ; 1639 ;
1649 1640
1650compound_statement_lbrace: 1641compound_statement_lbrace:
1651 T_LBRACE { 1642 T_LBRACE {
1652 block_level++; 1643 block_level++;
1653 mem_block_level++; 1644 mem_block_level++;
1654 begin_declaration_level(AUTO); 1645 begin_declaration_level(AUTO);
1655 } 1646 }
1656 ; 1647 ;
1657 1648
1658compound_statement_rbrace: 1649compound_statement_rbrace:
1659 T_RBRACE { 1650 T_RBRACE {
1660 end_declaration_level(); 1651 end_declaration_level();
1661 freeblk(); 1652 freeblk();
1662 mem_block_level--; 1653 mem_block_level--;
1663 block_level--; 1654 block_level--;
1664 seen_fallthrough = false; 1655 seen_fallthrough = false;
1665 } 1656 }
1666 ; 1657 ;
1667 1658
1668block_item_list: /* C99 6.8.2 */ 1659block_item_list: /* C99 6.8.2 */
1669 block_item 1660 block_item
1670 | block_item_list block_item { 1661 | block_item_list block_item {
1671 if (!Sflag && $1 && !$2) 1662 if (!Sflag && $1 && !$2)
1672 /* declarations after statements is a C99 feature */ 1663 /* declarations after statements is a C99 feature */
1673 c99ism(327); 1664 c99ism(327);
1674 $$ = $1 || $2; 1665 $$ = $1 || $2;
1675 } 1666 }
1676 ; 1667 ;
1677 1668
1678block_item: /* C99 6.8.2 */ 1669block_item: /* C99 6.8.2 */
1679 declaration_or_error { 1670 declaration_or_error {
1680 $$ = false; 1671 $$ = false;
1681 restore_warning_flags(); 1672 restore_warning_flags();
1682 } 1673 }
1683 | statement { 1674 | statement {
1684 $$ = true; 1675 $$ = true;
1685 restore_warning_flags(); 1676 restore_warning_flags();
1686 } 1677 }
1687 ; 1678 ;
1688 1679
1689expression_statement: /* C99 6.8.3 */ 1680expression_statement: /* C99 6.8.3 */
1690 expression T_SEMI { 1681 expression T_SEMI {
1691 expr($1, false, false, false, false); 1682 expr($1, false, false, false, false);
1692 seen_fallthrough = false; 1683 seen_fallthrough = false;
1693 } 1684 }
1694 | T_SEMI { 1685 | T_SEMI {
1695 seen_fallthrough = false; 1686 seen_fallthrough = false;
1696 } 1687 }
1697 ; 1688 ;
1698 1689
1699selection_statement: /* C99 6.8.4 */ 1690selection_statement: /* C99 6.8.4 */
1700 if_without_else %prec T_THEN { 1691 if_without_else %prec T_THEN {
1701 save_warning_flags(); 1692 save_warning_flags();
1702 if2(); 1693 if2();
1703 if3(false); 1694 if3(false);
1704 } 1695 }
1705 | if_without_else T_ELSE { 1696 | if_without_else T_ELSE {
1706 save_warning_flags(); 1697 save_warning_flags();
1707 if2(); 1698 if2();
1708 } statement { 1699 } statement {
1709 clear_warning_flags(); 1700 clear_warning_flags();
1710 if3(true); 1701 if3(true);
1711 } 1702 }
1712 | if_without_else T_ELSE error { 1703 | if_without_else T_ELSE error {
1713 clear_warning_flags(); 1704 clear_warning_flags();
1714 if3(false); 1705 if3(false);
1715 } 1706 }
1716 | switch_expr statement { 1707 | switch_expr statement {
1717 clear_warning_flags(); 1708 clear_warning_flags();
1718 switch2(); 1709 switch2();
1719 } 1710 }
1720 | switch_expr error { 1711 | switch_expr error {
1721 clear_warning_flags(); 1712 clear_warning_flags();
1722 switch2(); 1713 switch2();
1723 } 1714 }
1724 ; 1715 ;
1725 1716
1726if_without_else: /* see C99 6.8.4 */ 1717if_without_else: /* see C99 6.8.4 */
1727 if_expr statement 1718 if_expr statement
1728 | if_expr error 1719 | if_expr error
1729 ; 1720 ;
1730 1721
1731if_expr: /* see C99 6.8.4 */ 1722if_expr: /* see C99 6.8.4 */
1732 T_IF T_LPAREN expression T_RPAREN { 1723 T_IF T_LPAREN expression T_RPAREN {
1733 if1($3); 1724 if1($3);
1734 clear_warning_flags(); 1725 clear_warning_flags();
1735 } 1726 }
1736 ; 1727 ;
1737 1728
1738switch_expr: /* see C99 6.8.4 */ 1729switch_expr: /* see C99 6.8.4 */
1739 T_SWITCH T_LPAREN expression T_RPAREN { 1730 T_SWITCH T_LPAREN expression T_RPAREN {
1740 switch1($3); 1731 switch1($3);
1741 clear_warning_flags(); 1732 clear_warning_flags();
1742 } 1733 }
1743 ; 1734 ;
1744 1735
1745iteration_statement: /* C99 6.8.5 */ 1736iteration_statement: /* C99 6.8.5 */
1746 while_expr statement { 1737 while_expr statement {
1747 clear_warning_flags(); 1738 clear_warning_flags();
1748 while2(); 1739 while2();
1749 } 1740 }
1750 | while_expr error { 1741 | while_expr error {
1751 clear_warning_flags(); 1742 clear_warning_flags();
1752 while2(); 1743 while2();
1753 } 1744 }
1754 | do_statement do_while_expr { 1745 | do_statement do_while_expr {
1755 do2($2); 1746 do2($2);
1756 seen_fallthrough = false; 1747 seen_fallthrough = false;
1757 } 1748 }
1758 | do error { 1749 | do error {
1759 clear_warning_flags(); 1750 clear_warning_flags();
1760 do2(NULL); 1751 do2(NULL);
1761 } 1752 }
1762 | for_exprs statement { 1753 | for_exprs statement {
1763 clear_warning_flags(); 1754 clear_warning_flags();
1764 for2(); 1755 for2();
1765 end_declaration_level(); 1756 end_declaration_level();
1766 block_level--; 1757 block_level--;
1767 } 1758 }
1768 | for_exprs error { 1759 | for_exprs error {
1769 clear_warning_flags(); 1760 clear_warning_flags();
1770 for2(); 1761 for2();
1771 end_declaration_level(); 1762 end_declaration_level();
1772 block_level--; 1763 block_level--;
1773 } 1764 }
1774 ; 1765 ;
1775 1766
1776while_expr: /* see C99 6.8.5 */ 1767while_expr: /* see C99 6.8.5 */
1777 T_WHILE T_LPAREN expression T_RPAREN { 1768 T_WHILE T_LPAREN expression T_RPAREN {
1778 while1($3); 1769 while1($3);
1779 clear_warning_flags(); 1770 clear_warning_flags();
1780 } 1771 }
1781 ; 1772 ;
1782 1773
1783do_statement: /* see C99 6.8.5 */ 1774do_statement: /* see C99 6.8.5 */
1784 do statement { 1775 do statement {
1785 clear_warning_flags(); 1776 clear_warning_flags();
1786 } 1777 }
1787 ; 1778 ;
1788 1779
1789do: /* see C99 6.8.5 */ 1780do: /* see C99 6.8.5 */
1790 T_DO { 1781 T_DO {
1791 do1(); 1782 do1();
1792 } 1783 }
1793 ; 1784 ;
1794 1785
1795do_while_expr: /* see C99 6.8.5 */ 1786do_while_expr: /* see C99 6.8.5 */
1796 T_WHILE T_LPAREN expression T_RPAREN T_SEMI { 1787 T_WHILE T_LPAREN expression T_RPAREN T_SEMI {
1797 $$ = $3; 1788 $$ = $3;
1798 } 1789 }
1799 ; 1790 ;
1800 1791
1801for_start: /* see C99 6.8.5 */ 1792for_start: /* see C99 6.8.5 */
1802 T_FOR T_LPAREN { 1793 T_FOR T_LPAREN {
1803 begin_declaration_level(AUTO); 1794 begin_declaration_level(AUTO);
1804 block_level++; 1795 block_level++;
1805 } 1796 }
1806 ; 1797 ;
1807 1798
1808for_exprs: /* see C99 6.8.5 */ 1799for_exprs: /* see C99 6.8.5 */
1809 for_start 1800 for_start
1810 begin_type_declaration_specifiers end_type 1801 begin_type_declaration_specifiers end_type
1811 notype_init_declarators T_SEMI 1802 notype_init_declarators T_SEMI
1812 expression_opt T_SEMI expression_opt T_RPAREN { 1803 expression_opt T_SEMI expression_opt T_RPAREN {
1813 /* variable declaration in for loop */ 1804 /* variable declaration in for loop */
1814 c99ism(325); 1805 c99ism(325);
1815 for1(NULL, $6, $8); 1806 for1(NULL, $6, $8);
1816 clear_warning_flags(); 1807 clear_warning_flags();
1817 } 1808 }
1818 | for_start 1809 | for_start
1819 expression_opt T_SEMI 1810 expression_opt T_SEMI
1820 expression_opt T_SEMI 1811 expression_opt T_SEMI
1821 expression_opt T_RPAREN { 1812 expression_opt T_RPAREN {
1822 for1($2, $4, $6); 1813 for1($2, $4, $6);
1823 clear_warning_flags(); 1814 clear_warning_flags();
1824 } 1815 }
1825 ; 1816 ;
1826 1817
1827jump_statement: /* C99 6.8.6 */ 1818jump_statement: /* C99 6.8.6 */
1828 goto identifier T_SEMI { 1819 goto identifier T_SEMI {
1829 do_goto(getsym($2)); 1820 do_goto(getsym($2));
1830 } 1821 }
1831 | goto error T_SEMI { 1822 | goto error T_SEMI {
1832 symtyp = FVFT; 1823 symtyp = FVFT;
1833 } 1824 }
1834 | T_CONTINUE T_SEMI { 1825 | T_CONTINUE T_SEMI {
1835 do_continue(); 1826 do_continue();
1836 } 1827 }
1837 | T_BREAK T_SEMI { 1828 | T_BREAK T_SEMI {
1838 do_break(); 1829 do_break();
1839 } 1830 }
1840 | T_RETURN T_SEMI { 1831 | T_RETURN T_SEMI {
1841 do_return(NULL); 1832 do_return(NULL);
1842 } 1833 }
1843 | T_RETURN expression T_SEMI { 1834 | T_RETURN expression T_SEMI {
1844 do_return($2); 1835 do_return($2);
1845 } 1836 }
1846 ; 1837 ;
1847 1838
1848goto: /* see C99 6.8.6 */ 1839goto: /* see C99 6.8.6 */
1849 T_GOTO { 1840 T_GOTO {
1850 symtyp = FLABEL; 1841 symtyp = FLABEL;
1851 } 1842 }
1852 ; 1843 ;
1853 1844
1854asm_statement: /* GCC extension */ 1845asm_statement: /* GCC extension */
1855 T_ASM T_LPAREN read_until_rparen T_SEMI { 1846 T_ASM T_LPAREN read_until_rparen T_SEMI {
1856 setasm(); 1847 setasm();
1857 } 1848 }
1858 | T_ASM T_QUAL T_LPAREN read_until_rparen T_SEMI { 1849 | T_ASM T_QUAL T_LPAREN read_until_rparen T_SEMI {
1859 setasm(); 1850 setasm();
1860 } 1851 }
1861 | T_ASM error 1852 | T_ASM error
1862 ; 1853 ;
1863 1854
1864read_until_rparen: /* helper for 'asm_statement' */ 1855read_until_rparen: /* helper for 'asm_statement' */
1865 /* empty */ { 1856 /* empty */ {
1866 ignore_up_to_rparen(); 1857 ignore_up_to_rparen();
1867 } 1858 }
1868 ; 1859 ;
1869 1860
1870translation_unit: /* C99 6.9 */ 1861translation_unit: /* C99 6.9 */
1871 external_declaration 1862 external_declaration
1872 | translation_unit external_declaration 1863 | translation_unit external_declaration
1873 ; 1864 ;
1874 1865
1875external_declaration: /* C99 6.9 */ 1866external_declaration: /* C99 6.9 */
1876 asm_statement 1867 asm_statement
1877 | function_definition { 1868 | function_definition {
1878 global_clean_up_decl(false); 1869 global_clean_up_decl(false);
1879 clear_warning_flags(); 1870 clear_warning_flags();
1880 } 1871 }
1881 | top_level_declaration { 1872 | top_level_declaration {
1882 global_clean_up_decl(false); 1873 global_clean_up_decl(false);
1883 clear_warning_flags(); 1874 clear_warning_flags();
1884 } 1875 }
1885 ; 1876 ;
1886 1877
1887/* 1878/*
1888 * On the top level, lint allows several forms of declarations that it doesn't 1879 * On the top level, lint allows several forms of declarations that it doesn't
1889 * allow in functions. For example, a single ';' is an empty declaration and 1880 * allow in functions. For example, a single ';' is an empty declaration and
1890 * is supported by some compilers, but in a function it would be an empty 1881 * is supported by some compilers, but in a function it would be an empty
1891 * statement, not a declaration. This makes a difference in C90 mode, where 1882 * statement, not a declaration. This makes a difference in C90 mode, where
1892 * a statement must not be followed by a declaration. 1883 * a statement must not be followed by a declaration.
1893 * 1884 *
1894 * See 'declaration' for all other declarations. 1885 * See 'declaration' for all other declarations.
1895 */ 1886 */
1896top_level_declaration: /* C99 6.9 calls this 'declaration' */ 1887top_level_declaration: /* C99 6.9 calls this 'declaration' */
1897 T_SEMI { 1888 T_SEMI {
1898 if (sflag) { 1889 if (sflag) {
1899 /* empty declaration */ 1890 /* empty declaration */
1900 error(0); 1891 error(0);
1901 } else if (!tflag) { 1892 } else if (!tflag) {
1902 /* empty declaration */ 1893 /* empty declaration */
1903 warning(0); 1894 warning(0);
1904 } 1895 }
1905 } 1896 }
1906 | begin_type end_type notype_init_declarators T_SEMI { 1897 | begin_type end_type notype_init_declarators T_SEMI {
1907 if (sflag) { 1898 if (sflag) {
1908 /* old style declaration; add 'int' */ 1899 /* old style declaration; add 'int' */
1909 error(1); 1900 error(1);
1910 } else if (!tflag) { 1901 } else if (!tflag) {
1911 /* old style declaration; add 'int' */ 1902 /* old style declaration; add 'int' */
1912 warning(1); 1903 warning(1);
1913 } 1904 }
1914 } 1905 }
1915 | declaration 1906 | declaration
1916 | error T_SEMI { 1907 | error T_SEMI {
1917 global_clean_up(); 1908 global_clean_up();
1918 } 1909 }
1919 | error T_RBRACE { 1910 | error T_RBRACE {
1920 global_clean_up(); 1911 global_clean_up();
1921 } 1912 }
1922 ; 1913 ;
1923 1914
1924function_definition: /* C99 6.9.1 */ 1915function_definition: /* C99 6.9.1 */
1925 func_declarator { 1916 func_declarator {
1926 if ($1->s_type->t_tspec != FUNC) { 1917 if ($1->s_type->t_tspec != FUNC) {
1927 /* syntax error '%s' */ 1918 /* syntax error '%s' */
1928 error(249, yytext); 1919 error(249, yytext);
1929 YYERROR; 1920 YYERROR;
1930 } 1921 }
1931 if ($1->s_type->t_typedef) { 1922 if ($1->s_type->t_typedef) {
1932 /* ()-less function definition */ 1923 /* ()-less function definition */
1933 error(64); 1924 error(64);
1934 YYERROR; 1925 YYERROR;
1935 } 1926 }
1936 funcdef($1); 1927 funcdef($1);
1937 block_level++; 1928 block_level++;
1938 begin_declaration_level(ARG); 1929 begin_declaration_level(ARG);
1939 if (lwarn == LWARN_NONE) 1930 if (lwarn == LWARN_NONE)
1940 $1->s_used = true; 1931 $1->s_used = true;
1941 } arg_declaration_list_opt { 1932 } arg_declaration_list_opt {
1942 end_declaration_level(); 1933 end_declaration_level();
1943 block_level--; 1934 block_level--;
1944 check_func_lint_directives(); 1935 check_func_lint_directives();
1945 check_func_old_style_arguments(); 1936 check_func_old_style_arguments();
1946 begin_control_statement(CS_FUNCTION_BODY); 1937 begin_control_statement(CS_FUNCTION_BODY);
1947 } compound_statement { 1938 } compound_statement {
1948 funcend(); 1939 funcend();
1949 end_control_statement(CS_FUNCTION_BODY); 1940 end_control_statement(CS_FUNCTION_BODY);
1950 } 1941 }
1951 ; 1942 ;
1952 1943
1953func_declarator: 1944func_declarator:
1954 begin_type end_type notype_declarator { 1945 begin_type end_type notype_declarator {
1955 $$ = $3; 1946 $$ = $3;
1956 } 1947 }
1957 | begin_type_declmods end_type notype_declarator { 1948 | begin_type_declmods end_type notype_declarator {
1958 $$ = $3; 1949 $$ = $3;
1959 } 1950 }
1960 | begin_type_declaration_specifiers end_type type_declarator { 1951 | begin_type_declaration_specifiers end_type type_declarator {
1961 $$ = $3; 1952 $$ = $3;
1962 } 1953 }
1963 ; 1954 ;
1964 1955
1965arg_declaration_list_opt: /* C99 6.9.1p13 example 1 */ 1956arg_declaration_list_opt: /* C99 6.9.1p13 example 1 */
1966 /* empty */ 1957 /* empty */
1967 | arg_declaration_list 1958 | arg_declaration_list
1968 ; 1959 ;
1969 1960
1970arg_declaration_list: /* C99 6.9.1p13 example 1 */ 1961arg_declaration_list: /* C99 6.9.1p13 example 1 */
1971 arg_declaration 1962 arg_declaration
1972 | arg_declaration_list arg_declaration 1963 | arg_declaration_list arg_declaration
1973 /* XXX or better "arg_declaration error" ? */ 1964 /* XXX or better "arg_declaration error" ? */
1974 | error 1965 | error
1975 ; 1966 ;
1976 1967
1977/* 1968/*
1978 * "arg_declaration" is separated from "declaration" because it 1969 * "arg_declaration" is separated from "declaration" because it
1979 * needs other error handling. 1970 * needs other error handling.
1980 */ 1971 */
1981arg_declaration: 1972arg_declaration:
1982 begin_type_declmods end_type T_SEMI { 1973 begin_type_declmods end_type T_SEMI {
1983 /* empty declaration */ 1974 /* empty declaration */
1984 warning(2); 1975 warning(2);
1985 } 1976 }
1986 | begin_type_declmods end_type notype_init_declarators T_SEMI 1977 | begin_type_declmods end_type notype_init_declarators T_SEMI
1987 | begin_type_declaration_specifiers end_type T_SEMI { 1978 | begin_type_declaration_specifiers end_type T_SEMI {
1988 if (!dcs->d_nonempty_decl) { 1979 if (!dcs->d_nonempty_decl) {
1989 /* empty declaration */ 1980 /* empty declaration */
1990 warning(2); 1981 warning(2);
1991 } else { 1982 } else {
1992 /* '%s' declared in argument declaration list */ 1983 /* '%s' declared in argument declaration list */

cvs diff -r1.129 -r1.130 src/usr.bin/xlint/lint1/err.c (switch to unified diff)

--- src/usr.bin/xlint/lint1/err.c 2021/07/13 22:01:34 1.129
+++ src/usr.bin/xlint/lint1/err.c 2021/07/15 20:05:49 1.130
@@ -1,682 +1,682 @@ @@ -1,682 +1,682 @@
1/* $NetBSD: err.c,v 1.129 2021/07/13 22:01:34 rillig Exp $ */ 1/* $NetBSD: err.c,v 1.130 2021/07/15 20:05:49 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software 15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement: 16 * must display the following acknowledgement:
17 * This product includes software developed by Jochen Pohl for 17 * This product includes software developed by Jochen Pohl for
18 * The NetBSD Project. 18 * The NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products 19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission. 20 * derived from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: err.c,v 1.129 2021/07/13 22:01:34 rillig Exp $"); 40__RCSID("$NetBSD: err.c,v 1.130 2021/07/15 20:05:49 rillig Exp $");
41#endif 41#endif
42 42
43#include <sys/types.h> 43#include <sys/types.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47#include "lint1.h" 47#include "lint1.h"
48 48
49/* number of errors found */ 49/* number of errors found */
50int nerr; 50int nerr;
51 51
52/* number of syntax errors */ 52/* number of syntax errors */
53int sytxerr; 53int sytxerr;
54 54
55 55
56const char *const msgs[] = { 56const char *const msgs[] = {
57 "empty declaration", /* 0 */ 57 "empty declaration", /* 0 */
58 "old style declaration; add 'int'", /* 1 */ 58 "old style declaration; add 'int'", /* 1 */
59 "empty declaration", /* 2 */ 59 "empty declaration", /* 2 */
60 "'%s' declared in argument declaration list", /* 3 */ 60 "'%s' declared in argument declaration list", /* 3 */
61 "illegal type combination", /* 4 */ 61 "illegal type combination", /* 4 */
62 "modifying typedef with '%s'; only qualifiers allowed", /* 5 */ 62 "modifying typedef with '%s'; only qualifiers allowed", /* 5 */
63 "use 'double' instead of 'long float'", /* 6 */ 63 "use 'double' instead of 'long float'", /* 6 */
64 "only one storage class allowed", /* 7 */ 64 "only one storage class allowed", /* 7 */
65 "illegal storage class", /* 8 */ 65 "illegal storage class", /* 8 */
66 "only register valid as formal parameter storage class", /* 9 */ 66 "only register valid as formal parameter storage class", /* 9 */
67 "duplicate '%s'", /* 10 */ 67 "duplicate '%s'", /* 10 */
68 "bit-field initializer out of range", /* 11 */ 68 "bit-field initializer out of range", /* 11 */
69 "compiler takes size of function", /* 12 */ 69 "compiler takes size of function", /* 12 */
70 "incomplete enum type: %s", /* 13 */ 70 "incomplete enum type: %s", /* 13 */
71 "compiler takes alignment of function", /* 14 */ 71 "compiler takes alignment of function", /* 14 */
72 "function returns illegal type", /* 15 */ 72 "function returns illegal type", /* 15 */
73 "array of function is illegal", /* 16 */ 73 "array of function is illegal", /* 16 */
74 "null dimension", /* 17 */ 74 "null dimension", /* 17 */
75 "illegal use of 'void'", /* 18 */ 75 "illegal use of 'void'", /* 18 */
76 "void type for '%s'", /* 19 */ 76 "void type for '%s'", /* 19 */
77 "negative array dimension (%d)", /* 20 */ 77 "negative array dimension (%d)", /* 20 */
78 "redeclaration of formal parameter %s", /* 21 */ 78 "redeclaration of formal parameter %s", /* 21 */
79 "incomplete or misplaced function definition", /* 22 */ 79 "incomplete or misplaced function definition", /* 22 */
80 "undefined label '%s'", /* 23 */ 80 "undefined label '%s'", /* 23 */
81 "cannot initialize function: %s", /* 24 */ 81 "cannot initialize function: %s", /* 24 */
82 "cannot initialize typedef: %s", /* 25 */ 82 "cannot initialize typedef: %s", /* 25 */
83 "cannot initialize extern declaration: %s", /* 26 */ 83 "cannot initialize extern declaration: %s", /* 26 */
84 "redeclaration of %s", /* 27 */ 84 "redeclaration of %s", /* 27 */
85 "redefinition of %s", /* 28 */ 85 "redefinition of %s", /* 28 */
86 "previously declared extern, becomes static: %s", /* 29 */ 86 "previously declared extern, becomes static: %s", /* 29 */
87 "redeclaration of %s; ANSI C requires static", /* 30 */ 87 "redeclaration of %s; ANSI C requires static", /* 30 */
88 "'%s' has incomplete type '%s'", /* 31 */ 88 "'%s' has incomplete type '%s'", /* 31 */
89 "argument type defaults to 'int': %s", /* 32 */ 89 "argument type defaults to 'int': %s", /* 32 */
90 "duplicate member name: %s", /* 33 */ 90 "duplicate member name: %s", /* 33 */
91 "nonportable bit-field type '%s'", /* 34 */ 91 "nonportable bit-field type '%s'", /* 34 */
92 "illegal bit-field type '%s'", /* 35 */ 92 "illegal bit-field type '%s'", /* 35 */
93 "illegal bit-field size: %d", /* 36 */ 93 "illegal bit-field size: %d", /* 36 */
94 "zero size bit-field", /* 37 */ 94 "zero size bit-field", /* 37 */
95 "function illegal in structure or union", /* 38 */ 95 "function illegal in structure or union", /* 38 */
96 "zero sized array in struct is a C99 extension: %s", /* 39 */ 96 "zero sized array in struct is a C99 extension: %s", /* 39 */
97 "unknown size: %s", /* 40 */ 97 "unknown size: %s", /* 40 */
98 "illegal use of bit-field", /* 41 */ 98 "illegal use of bit-field", /* 41 */
99 "forward reference to enum type", /* 42 */ 99 "forward reference to enum type", /* 42 */
100 "redefinition hides earlier one: %s", /* 43 */ 100 "redefinition hides earlier one: %s", /* 43 */
101 "declaration introduces new type in ANSI C: %s %s", /* 44 */ 101 "declaration introduces new type in ANSI C: %s %s", /* 44 */
102 "base type is really '%s %s'", /* 45 */ 102 "base type is really '%s %s'", /* 45 */
103 "(%s) tag redeclared", /* 46 */ 103 "(%s) tag redeclared", /* 46 */
104 "zero sized %s is a C9X feature", /* 47 */ 104 "zero sized %s is a C9X feature", /* 47 */
105 "overflow in enumeration values: %s", /* 48 */ 105 "overflow in enumeration values: %s", /* 48 */
106 "anonymous struct/union members is a C9X feature", /* 49 */ 106 "anonymous struct/union members is a C9X feature", /* 49 */
107 "a function is declared as an argument: %s", /* 50 */ 107 "a function is declared as an argument: %s", /* 50 */
108 "parameter mismatch: %d declared, %d defined", /* 51 */ 108 "parameter mismatch: %d declared, %d defined", /* 51 */
109 "cannot initialize parameter: %s", /* 52 */ 109 "cannot initialize parameter: %s", /* 52 */
110 "declared argument %s is missing", /* 53 */ 110 "declared argument %s is missing", /* 53 */
111 "trailing ',' prohibited in enum declaration", /* 54 */ 111 "trailing ',' prohibited in enum declaration", /* 54 */
112 "integral constant expression expected", /* 55 */ 112 "integral constant expression expected", /* 55 */
113 "integral constant too large", /* 56 */ 113 "integral constant too large", /* 56 */
114 "enumeration constant hides parameter: %s", /* 57 */ 114 "enumeration constant hides parameter: %s", /* 57 */
115 "type does not match prototype: %s", /* 58 */ 115 "type does not match prototype: %s", /* 58 */
116 "formal parameter lacks name: param #%d", /* 59 */ 116 "formal parameter lacks name: param #%d", /* 59 */
117 "void must be sole parameter", /* 60 */ 117 "void must be sole parameter", /* 60 */
118 "void parameter cannot have name: %s", /* 61 */ 118 "void parameter cannot have name: %s", /* 61 */
119 "function prototype parameters must have types", /* 62 */ 119 "function prototype parameters must have types", /* 62 */
120 "prototype does not match old-style definition", /* 63 */ 120 "prototype does not match old-style definition", /* 63 */
121 "()-less function definition", /* 64 */ 121 "()-less function definition", /* 64 */
122 "%s has no named members", /* 65 */ 122 "%s has no named members", /* 65 */
123 "syntax requires ';' after last struct/union member", /* 66 */ 123 "", /* 66 */
124 "cannot return incomplete type", /* 67 */ 124 "cannot return incomplete type", /* 67 */
125 "typedef already qualified with '%s'", /* 68 */ 125 "typedef already qualified with '%s'", /* 68 */
126 "inappropriate qualifiers with 'void'", /* 69 */ 126 "inappropriate qualifiers with 'void'", /* 69 */
127 "%soperand of '%s' is unsigned in ANSI C", /* 70 */ 127 "%soperand of '%s' is unsigned in ANSI C", /* 70 */
128 "too many characters in character constant", /* 71 */ 128 "too many characters in character constant", /* 71 */
129 "typedef declares no type name", /* 72 */ 129 "typedef declares no type name", /* 72 */
130 "empty character constant", /* 73 */ 130 "empty character constant", /* 73 */
131 "no hex digits follow \\x", /* 74 */ 131 "no hex digits follow \\x", /* 74 */
132 "overflow in hex escape", /* 75 */ 132 "overflow in hex escape", /* 75 */
133 "character escape does not fit in character", /* 76 */ 133 "character escape does not fit in character", /* 76 */
134 "bad octal digit %c", /* 77 */ 134 "bad octal digit %c", /* 77 */
135 "nonportable character escape", /* 78 */ 135 "nonportable character escape", /* 78 */
136 "dubious escape \\%c", /* 79 */ 136 "dubious escape \\%c", /* 79 */
137 "dubious escape \\%o", /* 80 */ 137 "dubious escape \\%o", /* 80 */
138 "\\a undefined in traditional C", /* 81 */ 138 "\\a undefined in traditional C", /* 81 */
139 "\\x undefined in traditional C", /* 82 */ 139 "\\x undefined in traditional C", /* 82 */
140 "storage class after type is obsolescent", /* 83 */ 140 "storage class after type is obsolescent", /* 83 */
141 "ANSI C requires formal parameter before '...'", /* 84 */ 141 "ANSI C requires formal parameter before '...'", /* 84 */
142 "dubious tag declaration: %s %s", /* 85 */ 142 "dubious tag declaration: %s %s", /* 85 */
143 "automatic hides external declaration: %s", /* 86 */ 143 "automatic hides external declaration: %s", /* 86 */
144 "static hides external declaration: %s", /* 87 */ 144 "static hides external declaration: %s", /* 87 */
145 "typedef hides external declaration: %s", /* 88 */ 145 "typedef hides external declaration: %s", /* 88 */
146 "typedef redeclared: %s", /* 89 */ 146 "typedef redeclared: %s", /* 89 */
147 "inconsistent redeclaration of extern: %s", /* 90 */ 147 "inconsistent redeclaration of extern: %s", /* 90 */
148 "declaration hides parameter: %s", /* 91 */ 148 "declaration hides parameter: %s", /* 91 */
149 "inconsistent redeclaration of static: %s", /* 92 */ 149 "inconsistent redeclaration of static: %s", /* 92 */
150 "dubious static function at block level: %s", /* 93 */ 150 "dubious static function at block level: %s", /* 93 */
151 "function has illegal storage class: %s", /* 94 */ 151 "function has illegal storage class: %s", /* 94 */
152 "declaration hides earlier one: %s", /* 95 */ 152 "declaration hides earlier one: %s", /* 95 */
153 "cannot dereference non-pointer type", /* 96 */ 153 "cannot dereference non-pointer type", /* 96 */
154 "suffix U is illegal in traditional C", /* 97 */ 154 "suffix U is illegal in traditional C", /* 97 */
155 "suffixes F and L are illegal in traditional C", /* 98 */ 155 "suffixes F and L are illegal in traditional C", /* 98 */
156 "'%s' undefined", /* 99 */ 156 "'%s' undefined", /* 99 */
157 "unary + is illegal in traditional C", /* 100 */ 157 "unary + is illegal in traditional C", /* 100 */
158 "type '%s' does not have member '%s'", /* 101 */ 158 "type '%s' does not have member '%s'", /* 101 */
159 "illegal member use: %s", /* 102 */ 159 "illegal member use: %s", /* 102 */
160 "left operand of '.' must be struct or union, not '%s'", /* 103 */ 160 "left operand of '.' must be struct or union, not '%s'", /* 103 */
161 "left operand of '->' must be pointer to struct or union, not '%s'", /* 104 */ 161 "left operand of '->' must be pointer to struct or union, not '%s'", /* 104 */
162 "non-unique member requires struct/union %s", /* 105 */ 162 "non-unique member requires struct/union %s", /* 105 */
163 "left operand of '->' must be pointer", /* 106 */ 163 "left operand of '->' must be pointer", /* 106 */
164 "operands of '%s' have incompatible types (%s != %s)", /* 107 */ 164 "operands of '%s' have incompatible types (%s != %s)", /* 107 */
165 "operand of '%s' has invalid type (%s)", /* 108 */ 165 "operand of '%s' has invalid type (%s)", /* 108 */
166 "void type illegal in expression", /* 109 */ 166 "void type illegal in expression", /* 109 */
167 "pointer to function is not allowed here", /* 110 */ 167 "pointer to function is not allowed here", /* 110 */
168 "unacceptable operand of '%s'", /* 111 */ 168 "unacceptable operand of '%s'", /* 111 */
169 "cannot take address of bit-field", /* 112 */ 169 "cannot take address of bit-field", /* 112 */
170 "cannot take address of register %s", /* 113 */ 170 "cannot take address of register %s", /* 113 */
171 "%soperand of '%s' must be lvalue", /* 114 */ 171 "%soperand of '%s' must be lvalue", /* 114 */
172 "%soperand of '%s' must be modifiable lvalue", /* 115 */ 172 "%soperand of '%s' must be modifiable lvalue", /* 115 */
173 "illegal pointer subtraction", /* 116 */ 173 "illegal pointer subtraction", /* 116 */
174 "bitwise '%s' on signed value possibly nonportable", /* 117 */ 174 "bitwise '%s' on signed value possibly nonportable", /* 117 */
175 "semantics of '%s' change in ANSI C; use explicit cast", /* 118 */ 175 "semantics of '%s' change in ANSI C; use explicit cast", /* 118 */
176 "conversion of '%s' to '%s' is out of range", /* 119 */ 176 "conversion of '%s' to '%s' is out of range", /* 119 */
177 "bitwise '%s' on signed value nonportable", /* 120 */ 177 "bitwise '%s' on signed value nonportable", /* 120 */
178 "negative shift", /* 121 */ 178 "negative shift", /* 121 */
179 "shift amount %llu is greater than bit-size %llu of '%s'", /* 122 */ 179 "shift amount %llu is greater than bit-size %llu of '%s'", /* 122 */
180 "illegal combination of %s (%s) and %s (%s), op %s", /* 123 */ 180 "illegal combination of %s (%s) and %s (%s), op %s", /* 123 */
181 "illegal pointer combination (%s) and (%s), op %s", /* 124 */ 181 "illegal pointer combination (%s) and (%s), op %s", /* 124 */
182 "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */ 182 "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
183 "incompatible types '%s' and '%s' in conditional", /* 126 */ 183 "incompatible types '%s' and '%s' in conditional", /* 126 */
184 "'&' before array or function: ignored", /* 127 */ 184 "'&' before array or function: ignored", /* 127 */
185 "operands have incompatible pointer types, op %s (%s != %s)", /* 128 */ 185 "operands have incompatible pointer types, op %s (%s != %s)", /* 128 */
186 "expression has null effect", /* 129 */ 186 "expression has null effect", /* 129 */
187 "enum type mismatch: '%s' '%s' '%s'", /* 130 */ 187 "enum type mismatch: '%s' '%s' '%s'", /* 130 */
188 "conversion to '%s' may sign-extend incorrectly", /* 131 */ 188 "conversion to '%s' may sign-extend incorrectly", /* 131 */
189 "conversion from '%s' to '%s' may lose accuracy", /* 132 */ 189 "conversion from '%s' to '%s' may lose accuracy", /* 132 */
190 "conversion of pointer to '%s' loses bits", /* 133 */ 190 "conversion of pointer to '%s' loses bits", /* 133 */
191 "conversion of pointer to '%s' may lose bits", /* 134 */ 191 "conversion of pointer to '%s' may lose bits", /* 134 */
192 "converting '%s' to '%s' may cause alignment problem", /* 135 */ 192 "converting '%s' to '%s' may cause alignment problem", /* 135 */
193 "cannot do pointer arithmetic on operand of unknown size", /* 136 */ 193 "cannot do pointer arithmetic on operand of unknown size", /* 136 */
194 "use of incomplete enum type, op %s", /* 137 */ 194 "use of incomplete enum type, op %s", /* 137 */
195 "unknown operand size, op %s", /* 138 */ 195 "unknown operand size, op %s", /* 138 */
196 "division by 0", /* 139 */ 196 "division by 0", /* 139 */
197 "modulus by 0", /* 140 */ 197 "modulus by 0", /* 140 */
198 "integer overflow detected, op %s", /* 141 */ 198 "integer overflow detected, op %s", /* 141 */
199 "floating point overflow detected, op %s", /* 142 */ 199 "floating point overflow detected, op %s", /* 142 */
200 "cannot take size/alignment of incomplete type", /* 143 */ 200 "cannot take size/alignment of incomplete type", /* 143 */
201 "cannot take size/alignment of function", /* 144 */ 201 "cannot take size/alignment of function", /* 144 */
202 "cannot take size/alignment of bit-field", /* 145 */ 202 "cannot take size/alignment of bit-field", /* 145 */
203 "cannot take size/alignment of void", /* 146 */ 203 "cannot take size/alignment of void", /* 146 */
204 "invalid cast expression", /* 147 */ 204 "invalid cast expression", /* 147 */
205 "improper cast of void expression", /* 148 */ 205 "improper cast of void expression", /* 148 */
206 "illegal function (type %s)", /* 149 */ 206 "illegal function (type %s)", /* 149 */
207 "argument mismatch: %d arg%s passed, %d expected", /* 150 */ 207 "argument mismatch: %d arg%s passed, %d expected", /* 150 */
208 "void expressions may not be arguments, arg #%d", /* 151 */ 208 "void expressions may not be arguments, arg #%d", /* 151 */
209 "argument cannot have unknown size, arg #%d", /* 152 */ 209 "argument cannot have unknown size, arg #%d", /* 152 */
210 "converting '%s' to incompatible '%s' for argument %d", /* 153 */ 210 "converting '%s' to incompatible '%s' for argument %d", /* 153 */
211 "illegal combination of %s (%s) and %s (%s), arg #%d", /* 154 */ 211 "illegal combination of %s (%s) and %s (%s), arg #%d", /* 154 */
212 "passing '%s' to incompatible '%s', arg #%d", /* 155 */ 212 "passing '%s' to incompatible '%s', arg #%d", /* 155 */
213 "enum type mismatch, arg #%d (%s != %s)", /* 156 */ 213 "enum type mismatch, arg #%d (%s != %s)", /* 156 */
214 "ANSI C treats constant as unsigned", /* 157 */ 214 "ANSI C treats constant as unsigned", /* 157 */
215 "%s may be used before set", /* 158 */ 215 "%s may be used before set", /* 158 */
216 "assignment in conditional context", /* 159 */ 216 "assignment in conditional context", /* 159 */
217 "operator '==' found where '=' was expected", /* 160 */ 217 "operator '==' found where '=' was expected", /* 160 */
218 "constant in conditional context", /* 161 */ 218 "constant in conditional context", /* 161 */
219 "comparison of %s with %s, op %s", /* 162 */ 219 "comparison of %s with %s, op %s", /* 162 */
220 "a cast does not yield an lvalue", /* 163 */ 220 "a cast does not yield an lvalue", /* 163 */
221 "assignment of negative constant to unsigned type", /* 164 */ 221 "assignment of negative constant to unsigned type", /* 164 */
222 "constant truncated by assignment", /* 165 */ 222 "constant truncated by assignment", /* 165 */
223 "precision lost in bit-field assignment", /* 166 */ 223 "precision lost in bit-field assignment", /* 166 */
224 "array subscript cannot be negative: %ld", /* 167 */ 224 "array subscript cannot be negative: %ld", /* 167 */
225 "array subscript cannot be > %d: %ld", /* 168 */ 225 "array subscript cannot be > %d: %ld", /* 168 */
226 "precedence confusion possible: parenthesize!", /* 169 */ 226 "precedence confusion possible: parenthesize!", /* 169 */
227 "first operand must have scalar type, op ? :", /* 170 */ 227 "first operand must have scalar type, op ? :", /* 170 */
228 "cannot assign to '%s' from '%s'", /* 171 */ 228 "cannot assign to '%s' from '%s'", /* 171 */
229 "too many struct/union initializers", /* 172 */ 229 "too many struct/union initializers", /* 172 */
230 "too many array initializers, expected %d", /* 173 */ 230 "too many array initializers, expected %d", /* 173 */
231 "too many initializers", /* 174 */ 231 "too many initializers", /* 174 */
232 "initialization of incomplete type '%s'", /* 175 */ 232 "initialization of incomplete type '%s'", /* 175 */
233 "", /* no longer used */ /* 176 */ 233 "", /* no longer used */ /* 176 */
234 "non-constant initializer", /* 177 */ 234 "non-constant initializer", /* 177 */
235 "initializer does not fit", /* 178 */ 235 "initializer does not fit", /* 178 */
236 "cannot initialize struct/union with no named member", /* 179 */ 236 "cannot initialize struct/union with no named member", /* 179 */
237 "bit-field initializer does not fit", /* 180 */ 237 "bit-field initializer does not fit", /* 180 */
238 "{}-enclosed initializer required", /* 181 */ 238 "{}-enclosed initializer required", /* 181 */
239 "incompatible pointer types (%s != %s)", /* 182 */ 239 "incompatible pointer types (%s != %s)", /* 182 */
240 "illegal combination of %s (%s) and %s (%s)", /* 183 */ 240 "illegal combination of %s (%s) and %s (%s)", /* 183 */
241 "illegal pointer combination", /* 184 */ 241 "illegal pointer combination", /* 184 */
242 "cannot initialize '%s' from '%s'", /* 185 */ 242 "cannot initialize '%s' from '%s'", /* 185 */
243 "bit-field initialization is illegal in traditional C", /* 186 */ 243 "bit-field initialization is illegal in traditional C", /* 186 */
244 "non-null byte ignored in string initializer", /* 187 */ 244 "non-null byte ignored in string initializer", /* 187 */
245 "no automatic aggregate initialization in traditional C", /* 188 */ 245 "no automatic aggregate initialization in traditional C", /* 188 */
246 "", /* no longer used */ /* 189 */ 246 "", /* no longer used */ /* 189 */
247 "empty array declaration: %s", /* 190 */ 247 "empty array declaration: %s", /* 190 */
248 "'%s' set but not used in function '%s'", /* 191 */ 248 "'%s' set but not used in function '%s'", /* 191 */
249 "'%s' unused in function '%s'", /* 192 */ 249 "'%s' unused in function '%s'", /* 192 */
250 "statement not reached", /* 193 */ 250 "statement not reached", /* 193 */
251 "label %s redefined", /* 194 */ 251 "label %s redefined", /* 194 */
252 "case not in switch", /* 195 */ 252 "case not in switch", /* 195 */
253 "case label affected by conversion", /* 196 */ 253 "case label affected by conversion", /* 196 */
254 "non-constant case expression", /* 197 */ 254 "non-constant case expression", /* 197 */
255 "non-integral case expression", /* 198 */ 255 "non-integral case expression", /* 198 */
256 "duplicate case in switch: %ld", /* 199 */ 256 "duplicate case in switch: %ld", /* 199 */
257 "duplicate case in switch: %lu", /* 200 */ 257 "duplicate case in switch: %lu", /* 200 */
258 "default outside switch", /* 201 */ 258 "default outside switch", /* 201 */
259 "duplicate default in switch", /* 202 */ 259 "duplicate default in switch", /* 202 */
260 "case label must be of type `int' in traditional C", /* 203 */ 260 "case label must be of type `int' in traditional C", /* 203 */
261 "controlling expressions must have scalar type", /* 204 */ 261 "controlling expressions must have scalar type", /* 204 */
262 "switch expression must have integral type", /* 205 */ 262 "switch expression must have integral type", /* 205 */
263 "enumeration value(s) not handled in switch", /* 206 */ 263 "enumeration value(s) not handled in switch", /* 206 */
264 "loop not entered at top", /* 207 */ 264 "loop not entered at top", /* 207 */
265 "break outside loop or switch", /* 208 */ 265 "break outside loop or switch", /* 208 */
266 "continue outside loop", /* 209 */ 266 "continue outside loop", /* 209 */
267 "enum type mismatch between '%s' and '%s' in initialization", /* 210 */ 267 "enum type mismatch between '%s' and '%s' in initialization", /* 210 */
268 "return value type mismatch (%s) and (%s)", /* 211 */ 268 "return value type mismatch (%s) and (%s)", /* 211 */
269 "cannot return incomplete type", /* 212 */ 269 "cannot return incomplete type", /* 212 */
270 "void function %s cannot return value", /* 213 */ 270 "void function %s cannot return value", /* 213 */
271 "function %s expects to return value", /* 214 */ 271 "function %s expects to return value", /* 214 */
272 "function '%s' implicitly declared to return int", /* 215 */ 272 "function '%s' implicitly declared to return int", /* 215 */
273 "function %s has return (e); and return;", /* 216 */ 273 "function %s has return (e); and return;", /* 216 */
274 "function %s falls off bottom without returning value", /* 217 */ 274 "function %s falls off bottom without returning value", /* 217 */
275 "ANSI C treats constant as unsigned, op %s", /* 218 */ 275 "ANSI C treats constant as unsigned, op %s", /* 218 */
276 "concatenated strings are illegal in traditional C", /* 219 */ 276 "concatenated strings are illegal in traditional C", /* 219 */
277 "fallthrough on case statement", /* 220 */ 277 "fallthrough on case statement", /* 220 */
278 "initialization of unsigned with negative constant", /* 221 */ 278 "initialization of unsigned with negative constant", /* 221 */
279 "conversion of negative constant to unsigned type", /* 222 */ 279 "conversion of negative constant to unsigned type", /* 222 */
280 "end-of-loop code not reached", /* 223 */ 280 "end-of-loop code not reached", /* 223 */
281 "cannot recover from previous errors", /* 224 */ 281 "cannot recover from previous errors", /* 224 */
282 "static function called but not defined: %s()", /* 225 */ 282 "static function called but not defined: %s()", /* 225 */
283 "static variable %s unused", /* 226 */ 283 "static variable %s unused", /* 226 */
284 "const object %s should have initializer", /* 227 */ 284 "const object %s should have initializer", /* 227 */
285 "function cannot return const or volatile object", /* 228 */ 285 "function cannot return const or volatile object", /* 228 */
286 "converting '%s' to '%s' is questionable", /* 229 */ 286 "converting '%s' to '%s' is questionable", /* 229 */
287 "nonportable character comparison, op %s", /* 230 */ 287 "nonportable character comparison, op %s", /* 230 */
288 "argument '%s' unused in function '%s'", /* 231 */ 288 "argument '%s' unused in function '%s'", /* 231 */
289 "label '%s' unused in function '%s'", /* 232 */ 289 "label '%s' unused in function '%s'", /* 232 */
290 "struct %s never defined", /* 233 */ 290 "struct %s never defined", /* 233 */
291 "union %s never defined", /* 234 */ 291 "union %s never defined", /* 234 */
292 "enum %s never defined", /* 235 */ 292 "enum %s never defined", /* 235 */
293 "static function %s unused", /* 236 */ 293 "static function %s unused", /* 236 */
294 "redeclaration of formal parameter %s", /* 237 */ 294 "redeclaration of formal parameter %s", /* 237 */
295 "initialization of union is illegal in traditional C", /* 238 */ 295 "initialization of union is illegal in traditional C", /* 238 */
296 "constant argument to '!'", /* 239 */ 296 "constant argument to '!'", /* 239 */
297 "assignment of different structures (%s != %s)", /* 240 */ 297 "assignment of different structures (%s != %s)", /* 240 */
298 "dubious operation on enum, op %s", /* 241 */ 298 "dubious operation on enum, op %s", /* 241 */
299 "combination of '%s' and '%s', op %s", /* 242 */ 299 "combination of '%s' and '%s', op %s", /* 242 */
300 "dubious comparison of enums, op %s", /* 243 */ 300 "dubious comparison of enums, op %s", /* 243 */
301 "illegal structure pointer combination", /* 244 */ 301 "illegal structure pointer combination", /* 244 */
302 "incompatible structure pointers: '%s' '%s' '%s'", /* 245 */ 302 "incompatible structure pointers: '%s' '%s' '%s'", /* 245 */
303 "dubious conversion of enum to '%s'", /* 246 */ 303 "dubious conversion of enum to '%s'", /* 246 */
304 "pointer cast from '%s' to '%s' may be troublesome", /* 247 */ 304 "pointer cast from '%s' to '%s' may be troublesome", /* 247 */
305 "floating-point constant out of range", /* 248 */ 305 "floating-point constant out of range", /* 248 */
306 "syntax error '%s'", /* 249 */ 306 "syntax error '%s'", /* 249 */
307 "unknown character \\%o", /* 250 */ 307 "unknown character \\%o", /* 250 */
308 "malformed integer constant", /* 251 */ 308 "malformed integer constant", /* 251 */
309 "integer constant out of range", /* 252 */ 309 "integer constant out of range", /* 252 */
310 "unterminated character constant", /* 253 */ 310 "unterminated character constant", /* 253 */
311 "newline in string or char constant", /* 254 */ 311 "newline in string or char constant", /* 254 */
312 "undefined or invalid # directive", /* 255 */ 312 "undefined or invalid # directive", /* 255 */
313 "unterminated comment", /* 256 */ 313 "unterminated comment", /* 256 */
314 "extra characters in lint comment", /* 257 */ 314 "extra characters in lint comment", /* 257 */
315 "unterminated string constant", /* 258 */ 315 "unterminated string constant", /* 258 */
316 "argument #%d is converted from '%s' to '%s' due to prototype", /* 259 */ 316 "argument #%d is converted from '%s' to '%s' due to prototype", /* 259 */
317 "previous declaration of %s", /* 260 */ 317 "previous declaration of %s", /* 260 */
318 "previous definition of %s", /* 261 */ 318 "previous definition of %s", /* 261 */
319 "\\\" inside character constants undefined in traditional C", /* 262 */ 319 "\\\" inside character constants undefined in traditional C", /* 262 */
320 "\\? undefined in traditional C", /* 263 */ 320 "\\? undefined in traditional C", /* 263 */
321 "\\v undefined in traditional C", /* 264 */ 321 "\\v undefined in traditional C", /* 264 */
322 "%s C does not support 'long long'", /* 265 */ 322 "%s C does not support 'long long'", /* 265 */
323 "'long double' is illegal in traditional C", /* 266 */ 323 "'long double' is illegal in traditional C", /* 266 */
324 "shift equal to size of object", /* 267 */ 324 "shift equal to size of object", /* 267 */
325 "variable declared inline: %s", /* 268 */ 325 "variable declared inline: %s", /* 268 */
326 "argument declared inline: %s", /* 269 */ 326 "argument declared inline: %s", /* 269 */
327 "function prototypes are illegal in traditional C", /* 270 */ 327 "function prototypes are illegal in traditional C", /* 270 */
328 "switch expression must be of type `int' in traditional C", /* 271 */ 328 "switch expression must be of type `int' in traditional C", /* 271 */
329 "empty translation unit", /* 272 */ 329 "empty translation unit", /* 272 */
330 "bit-field type '%s' invalid in ANSI C", /* 273 */ 330 "bit-field type '%s' invalid in ANSI C", /* 273 */
331 "ANSI C forbids comparison of %s with %s", /* 274 */ 331 "ANSI C forbids comparison of %s with %s", /* 274 */
332 "cast discards 'const' from type '%s'", /* 275 */ 332 "cast discards 'const' from type '%s'", /* 275 */
333 "__%s__ is illegal for type %s", /* 276 */ 333 "__%s__ is illegal for type %s", /* 276 */
334 "initialization of '%s' with '%s'", /* 277 */ 334 "initialization of '%s' with '%s'", /* 277 */
335 "combination of '%s' and '%s', arg #%d", /* 278 */ 335 "combination of '%s' and '%s', arg #%d", /* 278 */
336 "combination of '%s' and '%s' in return", /* 279 */ 336 "combination of '%s' and '%s' in return", /* 279 */
337 "must be outside function: /* %s */", /* 280 */ 337 "must be outside function: /* %s */", /* 280 */
338 "duplicate use of /* %s */", /* 281 */ 338 "duplicate use of /* %s */", /* 281 */
339 "must precede function definition: /* %s */", /* 282 */ 339 "must precede function definition: /* %s */", /* 282 */
340 "argument number mismatch with directive: /* %s */", /* 283 */ 340 "argument number mismatch with directive: /* %s */", /* 283 */
341 "fallthrough on default statement", /* 284 */ 341 "fallthrough on default statement", /* 284 */
342 "prototype declaration", /* 285 */ 342 "prototype declaration", /* 285 */
343 "function definition is not a prototype", /* 286 */ 343 "function definition is not a prototype", /* 286 */
344 "function declaration is not a prototype", /* 287 */ 344 "function declaration is not a prototype", /* 287 */
345 "dubious use of /* VARARGS */ with /* %s */", /* 288 */ 345 "dubious use of /* VARARGS */ with /* %s */", /* 288 */
346 "can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */", /* 289 */ 346 "can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */", /* 289 */
347 "static function %s declared but not defined", /* 290 */ 347 "static function %s declared but not defined", /* 290 */
348 "invalid multibyte character", /* 291 */ 348 "invalid multibyte character", /* 291 */
349 "cannot concatenate wide and regular string literals", /* 292 */ 349 "cannot concatenate wide and regular string literals", /* 292 */
350 "argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE", /* 293 */ 350 "argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE", /* 293 */
351 "multi-character character constant", /* 294 */ 351 "multi-character character constant", /* 294 */
352 "conversion of '%s' to '%s' is out of range, arg #%d", /* 295 */ 352 "conversion of '%s' to '%s' is out of range, arg #%d", /* 295 */
353 "conversion of negative constant to unsigned type, arg #%d", /* 296 */ 353 "conversion of negative constant to unsigned type, arg #%d", /* 296 */
354 "conversion to '%s' may sign-extend incorrectly, arg #%d", /* 297 */ 354 "conversion to '%s' may sign-extend incorrectly, arg #%d", /* 297 */
355 "conversion from '%s' to '%s' may lose accuracy, arg #%d", /* 298 */ 355 "conversion from '%s' to '%s' may lose accuracy, arg #%d", /* 298 */
356 "prototype does not match old style definition, arg #%d", /* 299 */ 356 "prototype does not match old style definition, arg #%d", /* 299 */
357 "old style definition", /* 300 */ 357 "old style definition", /* 300 */
358 "array of incomplete type", /* 301 */ 358 "array of incomplete type", /* 301 */
359 "%s returns pointer to automatic object", /* 302 */ 359 "%s returns pointer to automatic object", /* 302 */
360 "ANSI C forbids conversion of %s to %s", /* 303 */ 360 "ANSI C forbids conversion of %s to %s", /* 303 */
361 "ANSI C forbids conversion of %s to %s, arg #%d", /* 304 */ 361 "ANSI C forbids conversion of %s to %s, arg #%d", /* 304 */
362 "ANSI C forbids conversion of %s to %s, op %s", /* 305 */ 362 "ANSI C forbids conversion of %s to %s, op %s", /* 305 */
363 "constant truncated by conversion, op %s", /* 306 */ 363 "constant truncated by conversion, op %s", /* 306 */
364 "static variable %s set but not used", /* 307 */ 364 "static variable %s set but not used", /* 307 */
365 "invalid type for _Complex", /* 308 */ 365 "invalid type for _Complex", /* 308 */
366 "extra bits set to 0 in conversion of '%s' to '%s', op '%s'", /* 309 */ 366 "extra bits set to 0 in conversion of '%s' to '%s', op '%s'", /* 309 */
367 "symbol renaming can't be used on function arguments", /* 310 */ 367 "symbol renaming can't be used on function arguments", /* 310 */
368 "symbol renaming can't be used on automatic variables", /* 311 */ 368 "symbol renaming can't be used on automatic variables", /* 311 */
369 "%s C does not support // comments", /* 312 */ 369 "%s C does not support // comments", /* 312 */
370 "struct or union member name in initializer is a C9X feature",/* 313 */ 370 "struct or union member name in initializer is a C9X feature",/* 313 */
371 "%s is not a structure or a union", /* 314 */ 371 "%s is not a structure or a union", /* 314 */
372 "GCC style struct or union member name in initializer", /* 315 */ 372 "GCC style struct or union member name in initializer", /* 315 */
373 "__FUNCTION__/__PRETTY_FUNCTION__ is a GCC extension", /* 316 */ 373 "__FUNCTION__/__PRETTY_FUNCTION__ is a GCC extension", /* 316 */
374 "__func__ is a C9X feature", /* 317 */ 374 "__func__ is a C9X feature", /* 317 */
375 "variable array dimension is a C99/GCC extension", /* 318 */ 375 "variable array dimension is a C99/GCC extension", /* 318 */
376 "compound literals are a C9X/GCC extension", /* 319 */ 376 "compound literals are a C9X/GCC extension", /* 319 */
377 "({ }) is a GCC extension", /* 320 */ 377 "({ }) is a GCC extension", /* 320 */
378 "array initializer with designators is a C9X feature", /* 321 */ 378 "array initializer with designators is a C9X feature", /* 321 */
379 "zero sized array is a C99 extension", /* 322 */ 379 "zero sized array is a C99 extension", /* 322 */
380 "continue in 'do ... while (0)' loop", /* 323 */ 380 "continue in 'do ... while (0)' loop", /* 323 */
381 "suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */ 381 "suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */
382 "variable declaration in for loop", /* 325 */ 382 "variable declaration in for loop", /* 325 */
383 "%s attribute ignored for %s", /* 326 */ 383 "%s attribute ignored for %s", /* 326 */
384 "declarations after statements is a C99 feature", /* 327 */ 384 "declarations after statements is a C99 feature", /* 327 */
385 "union cast is a C9X feature", /* 328 */ 385 "union cast is a C9X feature", /* 328 */
386 "type '%s' is not a member of '%s'", /* 329 */ 386 "type '%s' is not a member of '%s'", /* 329 */
387 "operand of '%s' must be bool, not '%s'", /* 330 */ 387 "operand of '%s' must be bool, not '%s'", /* 330 */
388 "left operand of '%s' must be bool, not '%s'", /* 331 */ 388 "left operand of '%s' must be bool, not '%s'", /* 331 */
389 "right operand of '%s' must be bool, not '%s'", /* 332 */ 389 "right operand of '%s' must be bool, not '%s'", /* 332 */
390 "controlling expression must be bool, not '%s'", /* 333 */ 390 "controlling expression must be bool, not '%s'", /* 333 */
391 "argument #%d expects '%s', gets passed '%s'", /* 334 */ 391 "argument #%d expects '%s', gets passed '%s'", /* 334 */
392 "operand of '%s' must not be bool", /* 335 */ 392 "operand of '%s' must not be bool", /* 335 */
393 "left operand of '%s' must not be bool", /* 336 */ 393 "left operand of '%s' must not be bool", /* 336 */
394 "right operand of '%s' must not be bool", /* 337 */ 394 "right operand of '%s' must not be bool", /* 337 */
395 "option '%c' should be handled in the switch", /* 338 */ 395 "option '%c' should be handled in the switch", /* 338 */
396 "option '%c' should be listed in the options string", /* 339 */ 396 "option '%c' should be listed in the options string", /* 339 */
397 "initialization with '[a...b]' is a GCC extension", /* 340 */ 397 "initialization with '[a...b]' is a GCC extension", /* 340 */
398 "argument to '%s' must be 'unsigned char' or EOF, not '%s'", /* 341 */ 398 "argument to '%s' must be 'unsigned char' or EOF, not '%s'", /* 341 */
399 "argument to '%s' must be cast to 'unsigned char', not to '%s'", /* 342 */ 399 "argument to '%s' must be cast to 'unsigned char', not to '%s'", /* 342 */
400 "static array size is a C11 extension", /* 343 */ 400 "static array size is a C11 extension", /* 343 */
401 "bit-field of type plain 'int' has implementation-defined signedness", /* 344 */ 401 "bit-field of type plain 'int' has implementation-defined signedness", /* 344 */
402 "generic selection requires C11 or later", /* 345 */ 402 "generic selection requires C11 or later", /* 345 */
403}; 403};
404 404
405static struct include_level { 405static struct include_level {
406 const char *filename; 406 const char *filename;
407 int lineno; 407 int lineno;
408 struct include_level *by; 408 struct include_level *by;
409} *includes; 409} *includes;
410 410
411 411
412void 412void
413update_location(const char *filename, int lineno, bool is_begin, bool is_end) 413update_location(const char *filename, int lineno, bool is_begin, bool is_end)
414{ 414{
415 struct include_level *top; 415 struct include_level *top;
416 416
417 top = includes; 417 top = includes;
418 if (is_begin && top != NULL) 418 if (is_begin && top != NULL)
419 top->lineno = curr_pos.p_line; 419 top->lineno = curr_pos.p_line;
420 420
421 if (top == NULL || is_begin) { 421 if (top == NULL || is_begin) {
422 top = xmalloc(sizeof(*top)); 422 top = xmalloc(sizeof(*top));
423 top->filename = filename; 423 top->filename = filename;
424 top->lineno = lineno; 424 top->lineno = lineno;
425 top->by = includes; 425 top->by = includes;
426 includes = top; 426 includes = top;
427 } else { 427 } else {
428 if (is_end) { 428 if (is_end) {
429 includes = top->by; 429 includes = top->by;
430 free(top); 430 free(top);
431 top = includes; 431 top = includes;
432 } 432 }
433 if (top != NULL) { 433 if (top != NULL) {
434 top->filename = filename; 434 top->filename = filename;
435 top->lineno = lineno; 435 top->lineno = lineno;
436 } 436 }
437 } 437 }
438} 438}
439 439
440static void 440static void
441print_stack_trace(void) 441print_stack_trace(void)
442{ 442{
443 const struct include_level *top; 443 const struct include_level *top;
444 444
445 if ((top = includes) == NULL) 445 if ((top = includes) == NULL)
446 return; 446 return;
447 /* 447 /*
448 * Skip the innermost include level since it is already listed in the 448 * Skip the innermost include level since it is already listed in the
449 * diagnostic itself. Furthermore, its lineno is the line number of 449 * diagnostic itself. Furthermore, its lineno is the line number of
450 * the last '#' line, not the current line. 450 * the last '#' line, not the current line.
451 */ 451 */
452 for (top = top->by; top != NULL; top = top->by) 452 for (top = top->by; top != NULL; top = top->by)
453 printf("\tincluded from %s(%d)\n", top->filename, top->lineno); 453 printf("\tincluded from %s(%d)\n", top->filename, top->lineno);
454} 454}
455 455
456/* 456/*
457 * print a list of the messages with their ids 457 * print a list of the messages with their ids
458 */ 458 */
459void 459void
460msglist(void) 460msglist(void)
461{ 461{
462 size_t i; 462 size_t i;
463 463
464 for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++) 464 for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
465 printf("%zu\t%s\n", i, msgs[i]); 465 printf("%zu\t%s\n", i, msgs[i]);
466} 466}
467 467
468/* 468/*
469 * If Fflag is not set, lbasename() returns a pointer to the last 469 * If Fflag is not set, lbasename() returns a pointer to the last
470 * component of the path, otherwise it returns the argument. 470 * component of the path, otherwise it returns the argument.
471 */ 471 */
472static const char * 472static const char *
473lbasename(const char *path) 473lbasename(const char *path)
474{ 474{
475 const char *p, *base, *dir; 475 const char *p, *base, *dir;
476 476
477 if (Fflag) 477 if (Fflag)
478 return path; 478 return path;
479 479
480 p = base = dir = path; 480 p = base = dir = path;
481 while (*p != '\0') { 481 while (*p != '\0') {
482 if (*p++ == '/') { 482 if (*p++ == '/') {
483 dir = base; 483 dir = base;
484 base = p; 484 base = p;
485 } 485 }
486 } 486 }
487 return *base != '\0' ? base : dir; 487 return *base != '\0' ? base : dir;
488} 488}
489 489
490static void 490static void
491verror_at(int msgid, const pos_t *pos, va_list ap) 491verror_at(int msgid, const pos_t *pos, va_list ap)
492{ 492{
493 const char *fn; 493 const char *fn;
494 494
495 if (ERR_ISSET(msgid, &msgset)) 495 if (ERR_ISSET(msgid, &msgset))
496 return; 496 return;
497 497
498 fn = lbasename(pos->p_file); 498 fn = lbasename(pos->p_file);
499 (void)printf("%s(%d): error: ", fn, pos->p_line); 499 (void)printf("%s(%d): error: ", fn, pos->p_line);
500 (void)vprintf(msgs[msgid], ap); 500 (void)vprintf(msgs[msgid], ap);
501 (void)printf(" [%d]\n", msgid); 501 (void)printf(" [%d]\n", msgid);
502 nerr++; 502 nerr++;
503 print_stack_trace(); 503 print_stack_trace();
504} 504}
505 505
506static void 506static void
507vwarning_at(int msgid, const pos_t *pos, va_list ap) 507vwarning_at(int msgid, const pos_t *pos, va_list ap)
508{ 508{
509 const char *fn; 509 const char *fn;
510 510
511 if (ERR_ISSET(msgid, &msgset)) 511 if (ERR_ISSET(msgid, &msgset))
512 return; 512 return;
513 513
514#ifdef DEBUG 514#ifdef DEBUG
515 printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid); 515 printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid);
516#endif 516#endif
517 if (lwarn == LWARN_NONE || lwarn == msgid) 517 if (lwarn == LWARN_NONE || lwarn == msgid)
518 /* this warning is suppressed by a LINTED comment */ 518 /* this warning is suppressed by a LINTED comment */
519 return; 519 return;
520 520
521 fn = lbasename(pos->p_file); 521 fn = lbasename(pos->p_file);
522 (void)printf("%s(%d): warning: ", fn, pos->p_line); 522 (void)printf("%s(%d): warning: ", fn, pos->p_line);
523 (void)vprintf(msgs[msgid], ap); 523 (void)vprintf(msgs[msgid], ap);
524 (void)printf(" [%d]\n", msgid); 524 (void)printf(" [%d]\n", msgid);
525 if (wflag) 525 if (wflag)
526 nerr++; 526 nerr++;
527 print_stack_trace(); 527 print_stack_trace();
528} 528}
529 529
530static void 530static void
531vmessage_at(int msgid, const pos_t *pos, va_list ap) 531vmessage_at(int msgid, const pos_t *pos, va_list ap)
532{ 532{
533 const char *fn; 533 const char *fn;
534 534
535 if (ERR_ISSET(msgid, &msgset)) 535 if (ERR_ISSET(msgid, &msgset))
536 return; 536 return;
537 537
538 fn = lbasename(pos->p_file); 538 fn = lbasename(pos->p_file);
539 (void)printf("%s(%d): ", fn, pos->p_line); 539 (void)printf("%s(%d): ", fn, pos->p_line);
540 (void)vprintf(msgs[msgid], ap); 540 (void)vprintf(msgs[msgid], ap);
541 (void)printf(" [%d]\n", msgid); 541 (void)printf(" [%d]\n", msgid);
542 print_stack_trace(); 542 print_stack_trace();
543} 543}
544 544
545void 545void
546(error_at)(int msgid, const pos_t *pos, ...) 546(error_at)(int msgid, const pos_t *pos, ...)
547{ 547{
548 va_list ap; 548 va_list ap;
549 549
550 va_start(ap, pos); 550 va_start(ap, pos);
551 verror_at(msgid, pos, ap); 551 verror_at(msgid, pos, ap);
552 va_end(ap); 552 va_end(ap);
553} 553}
554 554
555void 555void
556(error)(int msgid, ...) 556(error)(int msgid, ...)
557{ 557{
558 va_list ap; 558 va_list ap;
559 559
560 va_start(ap, msgid); 560 va_start(ap, msgid);
561 verror_at(msgid, &curr_pos, ap); 561 verror_at(msgid, &curr_pos, ap);
562 va_end(ap); 562 va_end(ap);
563} 563}
564 564
565void 565void
566internal_error(const char *file, int line, const char *msg, ...) 566internal_error(const char *file, int line, const char *msg, ...)
567{ 567{
568 va_list ap; 568 va_list ap;
569 const char *fn; 569 const char *fn;
570 570
571 fn = lbasename(curr_pos.p_file); 571 fn = lbasename(curr_pos.p_file);
572 fflush(stdout); 572 fflush(stdout);
573 (void)fprintf(stderr, "lint: internal error in %s:%d near %s:%d: ", 573 (void)fprintf(stderr, "lint: internal error in %s:%d near %s:%d: ",
574 file, line, fn, curr_pos.p_line); 574 file, line, fn, curr_pos.p_line);
575 va_start(ap, msg); 575 va_start(ap, msg);
576 (void)vfprintf(stderr, msg, ap); 576 (void)vfprintf(stderr, msg, ap);
577 va_end(ap); 577 va_end(ap);
578 (void)fprintf(stderr, "\n"); 578 (void)fprintf(stderr, "\n");
579 print_stack_trace(); 579 print_stack_trace();
580 abort(); 580 abort();
581} 581}
582 582
583void 583void
584assert_failed(const char *file, int line, const char *func, const char *cond) 584assert_failed(const char *file, int line, const char *func, const char *cond)
585{ 585{
586 const char *fn; 586 const char *fn;
587 587
588 fn = lbasename(curr_pos.p_file); 588 fn = lbasename(curr_pos.p_file);
589 fflush(stdout); 589 fflush(stdout);
590 (void)fprintf(stderr, 590 (void)fprintf(stderr,
591 "lint: assertion \"%s\" failed in %s at %s:%d near %s:%d\n", 591 "lint: assertion \"%s\" failed in %s at %s:%d near %s:%d\n",
592 cond, func, file, line, fn, curr_pos.p_line); 592 cond, func, file, line, fn, curr_pos.p_line);
593 print_stack_trace(); 593 print_stack_trace();
594 abort(); 594 abort();
595} 595}
596 596
597void 597void
598(warning_at)(int msgid, const pos_t *pos, ...) 598(warning_at)(int msgid, const pos_t *pos, ...)
599{ 599{
600 va_list ap; 600 va_list ap;
601 601
602 va_start(ap, pos); 602 va_start(ap, pos);
603 vwarning_at(msgid, pos, ap); 603 vwarning_at(msgid, pos, ap);
604 va_end(ap); 604 va_end(ap);
605} 605}
606 606
607void 607void
608(warning)(int msgid, ...) 608(warning)(int msgid, ...)
609{ 609{
610 va_list ap; 610 va_list ap;
611 611
612 va_start(ap, msgid); 612 va_start(ap, msgid);
613 vwarning_at(msgid, &curr_pos, ap); 613 vwarning_at(msgid, &curr_pos, ap);
614 va_end(ap); 614 va_end(ap);
615} 615}
616 616
617void 617void
618(message_at)(int msgid, const pos_t *pos, ...) 618(message_at)(int msgid, const pos_t *pos, ...)
619{ 619{
620 va_list ap; 620 va_list ap;
621 621
622 va_start(ap, pos); 622 va_start(ap, pos);
623 vmessage_at(msgid, pos, ap); 623 vmessage_at(msgid, pos, ap);
624 va_end(ap); 624 va_end(ap);
625} 625}
626 626
627void 627void
628(message)(int msgid, ...) 628(message)(int msgid, ...)
629{ 629{
630 va_list ap; 630 va_list ap;
631 631
632 va_start(ap, msgid); 632 va_start(ap, msgid);
633 vmessage_at(msgid, &curr_pos, ap); 633 vmessage_at(msgid, &curr_pos, ap);
634 va_end(ap); 634 va_end(ap);
635} 635}
636 636
637/* 637/*
638 * XXX I think the logic is possibly somewhat screwed up here. The 638 * XXX I think the logic is possibly somewhat screwed up here. The
639 * question is, how do we want to interpret the -s and -S flags going 639 * question is, how do we want to interpret the -s and -S flags going
640 * forward? We need to answer that and then we can fix this to be 640 * forward? We need to answer that and then we can fix this to be
641 * "right"... [perry, 2 Nov 2002] 641 * "right"... [perry, 2 Nov 2002]
642*/ 642*/
643void 643void
644(c99ism)(int msgid, ...) 644(c99ism)(int msgid, ...)
645{ 645{
646 va_list ap; 646 va_list ap;
647 bool extensions_ok = Sflag || gflag; 647 bool extensions_ok = Sflag || gflag;
648 648
649 va_start(ap, msgid); 649 va_start(ap, msgid);
650 if (sflag && !extensions_ok) { 650 if (sflag && !extensions_ok) {
651 verror_at(msgid, &curr_pos, ap); 651 verror_at(msgid, &curr_pos, ap);
652 } else if (sflag || !extensions_ok) { 652 } else if (sflag || !extensions_ok) {
653 vwarning_at(msgid, &curr_pos, ap); 653 vwarning_at(msgid, &curr_pos, ap);
654 } 654 }
655 va_end(ap); 655 va_end(ap);
656} 656}
657 657
658void 658void
659(c11ism)(int msgid, ...) 659(c11ism)(int msgid, ...)
660{ 660{
661 va_list ap; 661 va_list ap;
662 662
663 if (c11flag || gflag) 663 if (c11flag || gflag)
664 return; 664 return;
665 va_start(ap, msgid); 665 va_start(ap, msgid);
666 verror_at(msgid, &curr_pos, ap); 666 verror_at(msgid, &curr_pos, ap);
667 va_end(ap); 667 va_end(ap);
668} 668}
669 669
670void 670void
671(gnuism)(int msgid, ...) 671(gnuism)(int msgid, ...)
672{ 672{
673 va_list ap; 673 va_list ap;
674 674
675 va_start(ap, msgid); 675 va_start(ap, msgid);
676 if (sflag && !gflag) { 676 if (sflag && !gflag) {
677 verror_at(msgid, &curr_pos, ap); 677 verror_at(msgid, &curr_pos, ap);
678 } else if (sflag || !gflag) { 678 } else if (sflag || !gflag) {
679 vwarning_at(msgid, &curr_pos, ap); 679 vwarning_at(msgid, &curr_pos, ap);
680 } 680 }
681 va_end(ap); 681 va_end(ap);
682} 682}