Mon Mar 6 11:58:31 2017 UTC ()
handle typeof in casts


(christos)
diff -r1.92 -r1.93 src/usr.bin/xlint/lint1/cgram.y

cvs diff -r1.92 -r1.93 src/usr.bin/xlint/lint1/cgram.y (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2017/01/07 18:28:49 1.92
+++ src/usr.bin/xlint/lint1/cgram.y 2017/03/06 11:58:31 1.93
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.92 2017/01/07 18:28:49 christos Exp $ */ 2/* $NetBSD: cgram.y,v 1.93 2017/03/06 11:58:31 christos 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
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
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.92 2017/01/07 18:28:49 christos Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.93 2017/03/06 11:58:31 christos Exp $");
39#endif 39#endif
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <string.h> 42#include <string.h>
43#include <limits.h> 43#include <limits.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48/* 48/*
49 * Contains the level of current declaration. 0 is extern. 49 * Contains the level of current declaration. 0 is extern.
50 * Used for symbol table entries. 50 * Used for symbol table entries.
51 */ 51 */
@@ -107,27 +107,27 @@ static inline void RESTORE(const char *f @@ -107,27 +107,27 @@ static inline void RESTORE(const char *f
107#define SAVE(f, l) olwarn = lwarn 107#define SAVE(f, l) olwarn = lwarn
108#define RESTORE(f, l) (void)(olwarn == LWARN_BAD ? (clrwflgs(), 0) : (lwarn = olwarn)) 108#define RESTORE(f, l) (void)(olwarn == LWARN_BAD ? (clrwflgs(), 0) : (lwarn = olwarn))
109#endif 109#endif
110 110
111/* unbind the anonymous struct members from the struct */ 111/* unbind the anonymous struct members from the struct */
112static void 112static void
113anonymize(sym_t *s) 113anonymize(sym_t *s)
114{ 114{
115 for ( ; s; s = s->s_nxt) 115 for ( ; s; s = s->s_nxt)
116 s->s_styp = NULL; 116 s->s_styp = NULL;
117} 117}
118%} 118%}
119 119
120%expect 100 120%expect 107
121 121
122%union { 122%union {
123 int y_int; 123 int y_int;
124 val_t *y_val; 124 val_t *y_val;
125 sbuf_t *y_sb; 125 sbuf_t *y_sb;
126 sym_t *y_sym; 126 sym_t *y_sym;
127 op_t y_op; 127 op_t y_op;
128 scl_t y_scl; 128 scl_t y_scl;
129 tspec_t y_tspec; 129 tspec_t y_tspec;
130 tqual_t y_tqual; 130 tqual_t y_tqual;
131 type_t *y_type; 131 type_t *y_type;
132 tnode_t *y_tnode; 132 tnode_t *y_tnode;
133 range_t y_range; 133 range_t y_range;
@@ -1352,27 +1352,30 @@ init_by_name: @@ -1352,27 +1352,30 @@ init_by_name:
1352init_lbrace: 1352init_lbrace:
1353 T_LBRACE { 1353 T_LBRACE {
1354 initlbr(); 1354 initlbr();
1355 } 1355 }
1356 ; 1356 ;
1357 1357
1358init_rbrace: 1358init_rbrace:
1359 T_RBRACE { 1359 T_RBRACE {
1360 initrbr(); 1360 initrbr();
1361 } 1361 }
1362 ; 1362 ;
1363 1363
1364type_name: 1364type_name:
1365 { 1365 T_TYPEOF term {
 1366 $$ = $2->tn_type;
 1367 }
 1368 | {
1366 pushdecl(ABSTRACT); 1369 pushdecl(ABSTRACT);
1367 } abstract_declaration { 1370 } abstract_declaration {
1368 popdecl(); 1371 popdecl();
1369 $$ = $2->s_type; 1372 $$ = $2->s_type;
1370 } 1373 }
1371 ; 1374 ;
1372 1375
1373abstract_declaration: 1376abstract_declaration:
1374 noclass_declmods deftyp { 1377 noclass_declmods deftyp {
1375 $$ = decl1abs(aname()); 1378 $$ = decl1abs(aname());
1376 } 1379 }
1377 | noclass_declspecs deftyp { 1380 | noclass_declspecs deftyp {
1378 $$ = decl1abs(aname()); 1381 $$ = decl1abs(aname());