cgram.y (256281) | cgram.y (281168) |
---|---|
1%{ | 1%{ |
2/* $NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $ */ | 2/* $NetBSD: cgram.y,v 1.40 2008/04/25 17:18:24 christos Exp $ */ |
3 4/* 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 6 * Copyright (c) 1994, 1995 Jochen Pohl 7 * All Rights Reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 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 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> 37#if defined(__RCSID) && !defined(lint) | 3 4/* 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 6 * Copyright (c) 1994, 1995 Jochen Pohl 7 * All Rights Reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 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 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> 37#if defined(__RCSID) && !defined(lint) |
38__RCSID("$NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $"); | 38__RCSID("$NetBSD: cgram.y,v 1.40 2008/04/25 17:18:24 christos Exp $"); |
39#endif | 39#endif |
40__FBSDID("$FreeBSD: stable/10/usr.bin/xlint/lint1/cgram.y 115967 2003-06-07 18:12:30Z obrien $"); | 40__FBSDID("$FreeBSD: stable/10/usr.bin/xlint/lint1/cgram.y 281168 2015-04-06 19:56:27Z pfg $"); |
41 42#include <stdlib.h> 43#include <string.h> 44#include <limits.h> 45 46#include "lint1.h" 47 48/* --- 11 unchanged lines hidden (view full) --- 60int mblklev; 61 62/* 63 * Save the no-warns state and restore it to avoid the problem where 64 * if (expr) { stmt } / * NOLINT * / stmt; 65 */ 66static int onowarn = -1; 67 | 41 42#include <stdlib.h> 43#include <string.h> 44#include <limits.h> 45 46#include "lint1.h" 47 48/* --- 11 unchanged lines hidden (view full) --- 60int mblklev; 61 62/* 63 * Save the no-warns state and restore it to avoid the problem where 64 * if (expr) { stmt } / * NOLINT * / stmt; 65 */ 66static int onowarn = -1; 67 |
68static int toicon(tnode_t *); | 68static int toicon(tnode_t *, int); |
69static void idecl(sym_t *, int, sbuf_t *); 70static void ignuptorp(void); 71 72#ifdef DEBUG | 69static void idecl(sym_t *, int, sbuf_t *); 70static void ignuptorp(void); 71 72#ifdef DEBUG |
73static __inline void CLRWFLGS(void); 74static __inline void CLRWFLGS(void) | 73static inline void CLRWFLGS(void); 74static inline void CLRWFLGS(void) |
75{ 76 printf("%s, %d: clear flags %s %d\n", curr_pos.p_file, 77 curr_pos.p_line, __FILE__, __LINE__); 78 clrwflgs(); 79 onowarn = -1; 80} 81 | 75{ 76 printf("%s, %d: clear flags %s %d\n", curr_pos.p_file, 77 curr_pos.p_line, __FILE__, __LINE__); 78 clrwflgs(); 79 onowarn = -1; 80} 81 |
82static __inline void SAVE(void); 83static __inline void SAVE(void) | 82static inline void SAVE(void); 83static inline void SAVE(void) |
84{ 85 if (onowarn != -1) 86 abort(); 87 printf("%s, %d: save flags %s %d = %d\n", curr_pos.p_file, 88 curr_pos.p_line, __FILE__, __LINE__, nowarn); 89 onowarn = nowarn; 90} 91 | 84{ 85 if (onowarn != -1) 86 abort(); 87 printf("%s, %d: save flags %s %d = %d\n", curr_pos.p_file, 88 curr_pos.p_line, __FILE__, __LINE__, nowarn); 89 onowarn = nowarn; 90} 91 |
92static __inline void RESTORE(void); 93static __inline void RESTORE(void) | 92static inline void RESTORE(void); 93static inline void RESTORE(void) |
94{ 95 if (onowarn != -1) { 96 nowarn = onowarn; 97 printf("%s, %d: restore flags %s %d = %d\n", curr_pos.p_file, 98 curr_pos.p_line, __FILE__, __LINE__, nowarn); 99 onowarn = -1; 100 } else 101 CLRWFLGS(); 102} 103#else 104#define CLRWFLGS() clrwflgs(), onowarn = -1 105#define SAVE() onowarn = nowarn 106#define RESTORE() (void)(onowarn == -1 ? (clrwflgs(), 0) : (nowarn = onowarn)) 107#endif 108%} 109 | 94{ 95 if (onowarn != -1) { 96 nowarn = onowarn; 97 printf("%s, %d: restore flags %s %d = %d\n", curr_pos.p_file, 98 curr_pos.p_line, __FILE__, __LINE__, nowarn); 99 onowarn = -1; 100 } else 101 CLRWFLGS(); 102} 103#else 104#define CLRWFLGS() clrwflgs(), onowarn = -1 105#define SAVE() onowarn = nowarn 106#define RESTORE() (void)(onowarn == -1 ? (clrwflgs(), 0) : (nowarn = onowarn)) 107#endif 108%} 109 |
110%expect 1 111 |
|
110%union { 111 int y_int; 112 val_t *y_val; 113 sbuf_t *y_sb; 114 sym_t *y_sym; 115 op_t y_op; 116 scl_t y_scl; 117 tspec_t y_tspec; 118 tqual_t y_tqual; 119 type_t *y_type; 120 tnode_t *y_tnode; | 112%union { 113 int y_int; 114 val_t *y_val; 115 sbuf_t *y_sb; 116 sym_t *y_sym; 117 op_t y_op; 118 scl_t y_scl; 119 tspec_t y_tspec; 120 tqual_t y_tqual; 121 type_t *y_type; 122 tnode_t *y_tnode; |
123 range_t y_range; |
|
121 strg_t *y_strg; 122 pqinf_t *y_pqinf; 123}; 124 125%token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPARN T_RPARN 126%token <y_op> T_STROP 127%token <y_op> T_UNOP 128%token <y_op> T_INCDEC --- 109 unchanged lines hidden (view full) --- 238%type <y_pqinf> type_qualifier 239%type <y_sym> identifier_list 240%type <y_sym> abs_decl 241%type <y_sym> direct_abs_decl 242%type <y_sym> vararg_parameter_type_list 243%type <y_sym> parameter_type_list 244%type <y_sym> parameter_declaration 245%type <y_tnode> expr | 124 strg_t *y_strg; 125 pqinf_t *y_pqinf; 126}; 127 128%token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPARN T_RPARN 129%token <y_op> T_STROP 130%token <y_op> T_UNOP 131%token <y_op> T_INCDEC --- 109 unchanged lines hidden (view full) --- 241%type <y_pqinf> type_qualifier 242%type <y_sym> identifier_list 243%type <y_sym> abs_decl 244%type <y_sym> direct_abs_decl 245%type <y_sym> vararg_parameter_type_list 246%type <y_sym> parameter_type_list 247%type <y_sym> parameter_declaration 248%type <y_tnode> expr |
249%type <y_tnode> expr_stmnt_val 250%type <y_tnode> expr_stmnt_list |
|
246%type <y_tnode> term 247%type <y_tnode> func_arg_list 248%type <y_op> point_or_arrow 249%type <y_type> type_name 250%type <y_sym> abstract_declaration 251%type <y_tnode> do_while_expr 252%type <y_tnode> opt_expr 253%type <y_strg> string 254%type <y_strg> string2 255%type <y_sb> opt_asm_or_symbolrename | 251%type <y_tnode> term 252%type <y_tnode> func_arg_list 253%type <y_op> point_or_arrow 254%type <y_type> type_name 255%type <y_sym> abstract_declaration 256%type <y_tnode> do_while_expr 257%type <y_tnode> opt_expr 258%type <y_strg> string 259%type <y_strg> string2 260%type <y_sb> opt_asm_or_symbolrename |
261%type <y_range> range 262%type <y_range> lorange |
|
256 257 258%% 259 260program: 261 /* empty */ { 262 if (sflag) { 263 /* empty translation unit */ --- 413 unchanged lines hidden (view full) --- 677 } 678 ; 679 680notype_member_decl: 681 notype_decl { 682 $$ = $1; 683 } 684 | notype_decl T_COLON constant { | 263 264 265%% 266 267program: 268 /* empty */ { 269 if (sflag) { 270 /* empty translation unit */ --- 413 unchanged lines hidden (view full) --- 684 } 685 ; 686 687notype_member_decl: 688 notype_decl { 689 $$ = $1; 690 } 691 | notype_decl T_COLON constant { |
685 $$ = bitfield($1, toicon($3)); | 692 $$ = bitfield($1, toicon($3, 1)); |
686 } 687 | { 688 symtyp = FVFT; 689 } T_COLON constant { | 693 } 694 | { 695 symtyp = FVFT; 696 } T_COLON constant { |
690 $$ = bitfield(NULL, toicon($3)); | 697 $$ = bitfield(NULL, toicon($3, 1)); |
691 } 692 ; 693 694type_member_decl: 695 type_decl { 696 $$ = $1; 697 } 698 | type_decl T_COLON constant { | 698 } 699 ; 700 701type_member_decl: 702 type_decl { 703 $$ = $1; 704 } 705 | type_decl T_COLON constant { |
699 $$ = bitfield($1, toicon($3)); | 706 $$ = bitfield($1, toicon($3, 1)); |
700 } 701 | { 702 symtyp = FVFT; 703 } T_COLON constant { | 707 } 708 | { 709 symtyp = FVFT; 710 } T_COLON constant { |
704 $$ = bitfield(NULL, toicon($3)); | 711 $$ = bitfield(NULL, toicon($3, 1)); |
705 } 706 ; 707 708enum_spec: 709 enum enum_tag { 710 $$ = mktag($2, ENUM, 0, 0); 711 } 712 | enum enum_tag { --- 66 unchanged lines hidden (view full) --- 779 } 780 ; 781 782enumerator: 783 ename { 784 $$ = ename($1, enumval, 1); 785 } 786 | ename T_ASSIGN constant { | 712 } 713 ; 714 715enum_spec: 716 enum enum_tag { 717 $$ = mktag($2, ENUM, 0, 0); 718 } 719 | enum enum_tag { --- 66 unchanged lines hidden (view full) --- 786 } 787 ; 788 789enumerator: 790 ename { 791 $$ = ename($1, enumval, 1); 792 } 793 | ename T_ASSIGN constant { |
787 $$ = ename($1, toicon($3), 0); | 794 $$ = ename($1, toicon($3, 1), 0); |
788 } 789 ; 790 791ename: 792 identifier { 793 $$ = getsym($1); 794 } 795 ; --- 48 unchanged lines hidden (view full) --- 844 } 845 | T_LPARN type_decl T_RPARN { 846 $$ = $2; 847 } 848 | notype_direct_decl T_LBRACK T_RBRACK { 849 $$ = addarray($1, 0, 0); 850 } 851 | notype_direct_decl T_LBRACK constant T_RBRACK { | 795 } 796 ; 797 798ename: 799 identifier { 800 $$ = getsym($1); 801 } 802 ; --- 48 unchanged lines hidden (view full) --- 851 } 852 | T_LPARN type_decl T_RPARN { 853 $$ = $2; 854 } 855 | notype_direct_decl T_LBRACK T_RBRACK { 856 $$ = addarray($1, 0, 0); 857 } 858 | notype_direct_decl T_LBRACK constant T_RBRACK { |
852 $$ = addarray($1, 1, toicon($3)); | 859 $$ = addarray($1, 1, toicon($3, 0)); |
853 } 854 | notype_direct_decl param_list { 855 $$ = addfunc($1, $2); 856 popdecl(); 857 blklev--; 858 } 859 ; 860 --- 12 unchanged lines hidden (view full) --- 873 } 874 | T_LPARN type_decl T_RPARN { 875 $$ = $2; 876 } 877 | type_direct_decl T_LBRACK T_RBRACK { 878 $$ = addarray($1, 0, 0); 879 } 880 | type_direct_decl T_LBRACK constant T_RBRACK { | 860 } 861 | notype_direct_decl param_list { 862 $$ = addfunc($1, $2); 863 popdecl(); 864 blklev--; 865 } 866 ; 867 --- 12 unchanged lines hidden (view full) --- 880 } 881 | T_LPARN type_decl T_RPARN { 882 $$ = $2; 883 } 884 | type_direct_decl T_LBRACK T_RBRACK { 885 $$ = addarray($1, 0, 0); 886 } 887 | type_direct_decl T_LBRACK constant T_RBRACK { |
881 $$ = addarray($1, 1, toicon($3)); | 888 $$ = addarray($1, 1, toicon($3, 0)); |
882 } 883 | type_direct_decl param_list { 884 $$ = addfunc($1, $2); 885 popdecl(); 886 blklev--; 887 } 888 ; 889 --- 19 unchanged lines hidden (view full) --- 909 } 910 | T_LPARN notype_param_decl T_RPARN { 911 $$ = $2; 912 } 913 | direct_param_decl T_LBRACK T_RBRACK { 914 $$ = addarray($1, 0, 0); 915 } 916 | direct_param_decl T_LBRACK constant T_RBRACK { | 889 } 890 | type_direct_decl param_list { 891 $$ = addfunc($1, $2); 892 popdecl(); 893 blklev--; 894 } 895 ; 896 --- 19 unchanged lines hidden (view full) --- 916 } 917 | T_LPARN notype_param_decl T_RPARN { 918 $$ = $2; 919 } 920 | direct_param_decl T_LBRACK T_RBRACK { 921 $$ = addarray($1, 0, 0); 922 } 923 | direct_param_decl T_LBRACK constant T_RBRACK { |
917 $$ = addarray($1, 1, toicon($3)); | 924 $$ = addarray($1, 1, toicon($3, 0)); |
918 } 919 | direct_param_decl param_list { 920 $$ = addfunc($1, $2); 921 popdecl(); 922 blklev--; 923 } 924 ; 925 --- 12 unchanged lines hidden (view full) --- 938 } 939 | T_LPARN notype_param_decl T_RPARN { 940 $$ = $2; 941 } 942 | direct_notype_param_decl T_LBRACK T_RBRACK { 943 $$ = addarray($1, 0, 0); 944 } 945 | direct_notype_param_decl T_LBRACK constant T_RBRACK { | 925 } 926 | direct_param_decl param_list { 927 $$ = addfunc($1, $2); 928 popdecl(); 929 blklev--; 930 } 931 ; 932 --- 12 unchanged lines hidden (view full) --- 945 } 946 | T_LPARN notype_param_decl T_RPARN { 947 $$ = $2; 948 } 949 | direct_notype_param_decl T_LBRACK T_RBRACK { 950 $$ = addarray($1, 0, 0); 951 } 952 | direct_notype_param_decl T_LBRACK constant T_RBRACK { |
946 $$ = addarray($1, 1, toicon($3)); | 953 $$ = addarray($1, 1, toicon($3, 0)); |
947 } 948 | direct_notype_param_decl param_list { 949 $$ = addfunc($1, $2); 950 popdecl(); 951 blklev--; 952 } 953 ; 954 --- 161 unchanged lines hidden (view full) --- 1116initializer: 1117 init_expr 1118 ; 1119 1120init_expr: 1121 expr %prec T_COMMA { 1122 mkinit($1); 1123 } | 954 } 955 | direct_notype_param_decl param_list { 956 $$ = addfunc($1, $2); 957 popdecl(); 958 blklev--; 959 } 960 ; 961 --- 161 unchanged lines hidden (view full) --- 1123initializer: 1124 init_expr 1125 ; 1126 1127init_expr: 1128 expr %prec T_COMMA { 1129 mkinit($1); 1130 } |
1131 | init_by_name init_expr %prec T_COMMA |
|
1124 | init_lbrace init_expr_list init_rbrace 1125 | init_lbrace init_expr_list T_COMMA init_rbrace 1126 | error 1127 ; 1128 1129init_expr_list: 1130 init_expr %prec T_COMMA 1131 | init_expr_list T_COMMA init_expr 1132 ; 1133 | 1132 | init_lbrace init_expr_list init_rbrace 1133 | init_lbrace init_expr_list T_COMMA init_rbrace 1134 | error 1135 ; 1136 1137init_expr_list: 1138 init_expr %prec T_COMMA 1139 | init_expr_list T_COMMA init_expr 1140 ; 1141 |
1142lorange: 1143 constant T_ELLIPSE { 1144 $$.lo = toicon($1, 1); 1145 } 1146 ; 1147range: 1148 constant { 1149 $$.lo = toicon($1, 1); 1150 $$.hi = $$.lo + 1; 1151 } 1152 | lorange constant { 1153 $$.lo = $1.lo; 1154 $$.hi = toicon($2, 1); 1155 } 1156 ; 1157 1158init_by_name: 1159 T_LBRACK range T_RBRACK T_ASSIGN { 1160 if (!Sflag) 1161 warning(321); 1162 } 1163 | point identifier T_ASSIGN { 1164 if (!Sflag) 1165 warning(313); 1166 memberpush($2); 1167 } 1168 | identifier T_COLON { 1169 gnuism(315); 1170 memberpush($1); 1171 } 1172 ; 1173 |
|
1134init_lbrace: 1135 T_LBRACE { 1136 initlbr(); 1137 } 1138 ; 1139 1140init_rbrace: 1141 T_RBRACE { --- 40 unchanged lines hidden (view full) --- 1182direct_abs_decl: 1183 T_LPARN abs_decl T_RPARN { 1184 $$ = $2; 1185 } 1186 | T_LBRACK T_RBRACK { 1187 $$ = addarray(aname(), 0, 0); 1188 } 1189 | T_LBRACK constant T_RBRACK { | 1174init_lbrace: 1175 T_LBRACE { 1176 initlbr(); 1177 } 1178 ; 1179 1180init_rbrace: 1181 T_RBRACE { --- 40 unchanged lines hidden (view full) --- 1222direct_abs_decl: 1223 T_LPARN abs_decl T_RPARN { 1224 $$ = $2; 1225 } 1226 | T_LBRACK T_RBRACK { 1227 $$ = addarray(aname(), 0, 0); 1228 } 1229 | T_LBRACK constant T_RBRACK { |
1190 $$ = addarray(aname(), 1, toicon($2)); | 1230 $$ = addarray(aname(), 1, toicon($2, 0)); |
1191 } 1192 | direct_abs_decl T_LBRACK T_RBRACK { 1193 $$ = addarray($1, 0, 0); 1194 } 1195 | direct_abs_decl T_LBRACK constant T_RBRACK { | 1231 } 1232 | direct_abs_decl T_LBRACK T_RBRACK { 1233 $$ = addarray($1, 0, 0); 1234 } 1235 | direct_abs_decl T_LBRACK constant T_RBRACK { |
1196 $$ = addarray($1, 1, toicon($3)); | 1236 $$ = addarray($1, 1, toicon($3, 0)); |
1197 } 1198 | abs_decl_param_list { 1199 $$ = addfunc(aname(), $1); 1200 popdecl(); 1201 blklev--; 1202 } 1203 | direct_abs_decl abs_decl_param_list { 1204 $$ = addfunc($1, $2); 1205 popdecl(); 1206 blklev--; 1207 } 1208 ; 1209 | 1237 } 1238 | abs_decl_param_list { 1239 $$ = addfunc(aname(), $1); 1240 popdecl(); 1241 blklev--; 1242 } 1243 | direct_abs_decl abs_decl_param_list { 1244 $$ = addfunc($1, $2); 1245 popdecl(); 1246 blklev--; 1247 } 1248 ; 1249 |
1210stmnt: | 1250non_expr_stmnt: |
1211 labeled_stmnt | 1251 labeled_stmnt |
1212 | expr_stmnt | |
1213 | comp_stmnt 1214 | selection_stmnt 1215 | iteration_stmnt 1216 | jump_stmnt { 1217 ftflg = 0; 1218 } 1219 | asm_stmnt | 1252 | comp_stmnt 1253 | selection_stmnt 1254 | iteration_stmnt 1255 | jump_stmnt { 1256 ftflg = 0; 1257 } 1258 | asm_stmnt |
1259 1260stmnt: 1261 expr_stmnt 1262 | non_expr_stmnt |
|
1220 ; 1221 1222labeled_stmnt: 1223 label stmnt 1224 ; 1225 1226label: 1227 identifier T_COLON { 1228 symtyp = FLAB; 1229 label(T_NAME, getsym($1), NULL); 1230 } 1231 | T_CASE constant T_COLON { 1232 label(T_CASE, NULL, $2); 1233 ftflg = 1; | 1263 ; 1264 1265labeled_stmnt: 1266 label stmnt 1267 ; 1268 1269label: 1270 identifier T_COLON { 1271 symtyp = FLAB; 1272 label(T_NAME, getsym($1), NULL); 1273 } 1274 | T_CASE constant T_COLON { 1275 label(T_CASE, NULL, $2); 1276 ftflg = 1; |
1234 } | 1277 } 1278 | T_CASE constant T_ELLIPSE constant T_COLON { 1279 /* XXX: We don't fill all cases */ 1280 label(T_CASE, NULL, $2); 1281 ftflg = 1; 1282 } |
1235 | T_DEFAULT T_COLON { 1236 label(T_DEFAULT, NULL, NULL); 1237 ftflg = 1; 1238 } 1239 ; 1240 1241comp_stmnt: | 1283 | T_DEFAULT T_COLON { 1284 label(T_DEFAULT, NULL, NULL); 1285 ftflg = 1; 1286 } 1287 ; 1288 1289comp_stmnt: |
1242 compstmnt_lbrace declaration_list opt_stmnt_list compstmnt_rbrace 1243 | compstmnt_lbrace opt_stmnt_list compstmnt_rbrace | 1290 comp_stmnt_lbrace declaration_list opt_stmnt_list comp_stmnt_rbrace 1291 | comp_stmnt_lbrace opt_stmnt_list comp_stmnt_rbrace |
1244 ; 1245 | 1292 ; 1293 |
1246compstmnt_lbrace: | 1294comp_stmnt_lbrace: |
1247 T_LBRACE { 1248 blklev++; 1249 mblklev++; 1250 pushdecl(AUTO); 1251 } 1252 ; 1253 | 1295 T_LBRACE { 1296 blklev++; 1297 mblklev++; 1298 pushdecl(AUTO); 1299 } 1300 ; 1301 |
1254compstmnt_rbrace: | 1302comp_stmnt_rbrace: |
1255 T_RBRACE { 1256 popdecl(); 1257 freeblk(); 1258 mblklev--; 1259 blklev--; 1260 ftflg = 0; 1261 } 1262 ; --- 8 unchanged lines hidden (view full) --- 1271 | stmnt_list stmnt { 1272 RESTORE(); 1273 } 1274 | stmnt_list error T_SEMI 1275 ; 1276 1277expr_stmnt: 1278 expr T_SEMI { | 1303 T_RBRACE { 1304 popdecl(); 1305 freeblk(); 1306 mblklev--; 1307 blklev--; 1308 ftflg = 0; 1309 } 1310 ; --- 8 unchanged lines hidden (view full) --- 1319 | stmnt_list stmnt { 1320 RESTORE(); 1321 } 1322 | stmnt_list error T_SEMI 1323 ; 1324 1325expr_stmnt: 1326 expr T_SEMI { |
1279 expr($1, 0, 0); | 1327 expr($1, 0, 0, 1); |
1280 ftflg = 0; 1281 } 1282 | T_SEMI { 1283 ftflg = 0; 1284 } 1285 ; 1286 | 1328 ftflg = 0; 1329 } 1330 | T_SEMI { 1331 ftflg = 0; 1332 } 1333 ; 1334 |
1335/* 1336 * The following two productions are used to implement 1337 * ({ [[decl-list] stmt-list] }). 1338 * XXX: This is not well tested. 1339 */ 1340expr_stmnt_val: 1341 expr T_SEMI { 1342 /* XXX: We should really do that only on the last name */ 1343 if ($1->tn_op == NAME) 1344 $1->tn_sym->s_used = 1; 1345 $$ = $1; 1346 expr($1, 0, 0, 0); 1347 ftflg = 0; 1348 } 1349 | non_expr_stmnt { 1350 $$ = getnode(); 1351 $$->tn_type = gettyp(VOID); 1352 } 1353 ; 1354 1355expr_stmnt_list: 1356 expr_stmnt_val 1357 | expr_stmnt_list expr_stmnt_val { 1358 $$ = $2; 1359 } 1360 | expr_stmnt_list expr_stmnt_val 1361 ; 1362 |
|
1287selection_stmnt: 1288 if_without_else { 1289 SAVE(); 1290 if2(); 1291 if3(0); 1292 } 1293 | if_without_else T_ELSE { 1294 SAVE(); --- 225 unchanged lines hidden (view full) --- 1520 | T_CON { 1521 $$ = getcnode(gettyp($1->v_tspec), $1); 1522 } 1523 | T_LPARN expr T_RPARN { 1524 if ($2 != NULL) 1525 $2->tn_parn = 1; 1526 $$ = $2; 1527 } | 1363selection_stmnt: 1364 if_without_else { 1365 SAVE(); 1366 if2(); 1367 if3(0); 1368 } 1369 | if_without_else T_ELSE { 1370 SAVE(); --- 225 unchanged lines hidden (view full) --- 1596 | T_CON { 1597 $$ = getcnode(gettyp($1->v_tspec), $1); 1598 } 1599 | T_LPARN expr T_RPARN { 1600 if ($2 != NULL) 1601 $2->tn_parn = 1; 1602 $$ = $2; 1603 } |
1604 | T_LPARN comp_stmnt_lbrace declaration_list expr_stmnt_list { 1605 blklev--; 1606 mblklev--; 1607 initsym = mktempsym(duptyp($4->tn_type)); 1608 mblklev++; 1609 blklev++; 1610 gnuism(320); 1611 } comp_stmnt_rbrace T_RPARN { 1612 $$ = getnnode(initsym, 0); 1613 } 1614 | T_LPARN comp_stmnt_lbrace expr_stmnt_list { 1615 blklev--; 1616 mblklev--; 1617 initsym = mktempsym($3->tn_type); 1618 mblklev++; 1619 blklev++; 1620 gnuism(320); 1621 } comp_stmnt_rbrace T_RPARN { 1622 $$ = getnnode(initsym, 0); 1623 } |
|
1528 | term T_INCDEC { 1529 $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL); 1530 } 1531 | T_INCDEC term { 1532 $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL); 1533 } 1534 | T_MULT term { 1535 $$ = build(STAR, $2, NULL); --- 39 unchanged lines hidden (view full) --- 1575 chkmisc($2, 0, 0, 0, 0, 0, 1); 1576 } 1577 | T_SIZEOF T_LPARN type_name T_RPARN %prec T_SIZEOF { 1578 $$ = bldszof($3); 1579 } 1580 | T_LPARN type_name T_RPARN term %prec T_UNOP { 1581 $$ = cast($4, $2); 1582 } | 1624 | term T_INCDEC { 1625 $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL); 1626 } 1627 | T_INCDEC term { 1628 $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL); 1629 } 1630 | T_MULT term { 1631 $$ = build(STAR, $2, NULL); --- 39 unchanged lines hidden (view full) --- 1671 chkmisc($2, 0, 0, 0, 0, 0, 1); 1672 } 1673 | T_SIZEOF T_LPARN type_name T_RPARN %prec T_SIZEOF { 1674 $$ = bldszof($3); 1675 } 1676 | T_LPARN type_name T_RPARN term %prec T_UNOP { 1677 $$ = cast($4, $2); 1678 } |
1679 | T_LPARN type_name T_RPARN %prec T_UNOP { 1680 sym_t *tmp = mktempsym($2); 1681 idecl(tmp, 1, NULL); 1682 } init_lbrace init_expr_list init_rbrace { 1683 if (!Sflag) 1684 gnuism(319); 1685 $$ = getnnode(initsym, 0); 1686 } |
|
1583 ; 1584 1585string: 1586 T_STRING { 1587 $$ = $1; 1588 } 1589 | T_STRING string2 { 1590 $$ = catstrg($1, $2); --- 24 unchanged lines hidden (view full) --- 1615 1616point_or_arrow: 1617 T_STROP { 1618 symtyp = FMOS; 1619 $$ = $1; 1620 } 1621 ; 1622 | 1687 ; 1688 1689string: 1690 T_STRING { 1691 $$ = $1; 1692 } 1693 | T_STRING string2 { 1694 $$ = catstrg($1, $2); --- 24 unchanged lines hidden (view full) --- 1719 1720point_or_arrow: 1721 T_STROP { 1722 symtyp = FMOS; 1723 $$ = $1; 1724 } 1725 ; 1726 |
1727point: 1728 T_STROP { 1729 if ($1 != POINT) 1730 error(249); 1731 } 1732 ; 1733 |
|
1623identifier: 1624 T_NAME { 1625 $$ = $1; 1626 } 1627 | T_TYPENAME { 1628 $$ = $1; 1629 } 1630 ; 1631 1632%% 1633 1634/* ARGSUSED */ 1635int 1636yyerror(char *msg) 1637{ | 1734identifier: 1735 T_NAME { 1736 $$ = $1; 1737 } 1738 | T_TYPENAME { 1739 $$ = $1; 1740 } 1741 ; 1742 1743%% 1744 1745/* ARGSUSED */ 1746int 1747yyerror(char *msg) 1748{ |
1638 | |
1639 error(249); 1640 if (++sytxerr >= 5) 1641 norecover(); 1642 return (0); 1643} 1644 1645static __inline int uq_gt(uint64_t, uint64_t); 1646static __inline int --- 18 unchanged lines hidden (view full) --- 1665 * as integer. 1666 * Is the node not constant or too large for int or of type float, 1667 * a warning will be printed. 1668 * 1669 * toicon() should be used only inside declarations. If it is used in 1670 * expressions, it frees the memory used for the expression. 1671 */ 1672static int | 1749 error(249); 1750 if (++sytxerr >= 5) 1751 norecover(); 1752 return (0); 1753} 1754 1755static __inline int uq_gt(uint64_t, uint64_t); 1756static __inline int --- 18 unchanged lines hidden (view full) --- 1775 * as integer. 1776 * Is the node not constant or too large for int or of type float, 1777 * a warning will be printed. 1778 * 1779 * toicon() should be used only inside declarations. If it is used in 1780 * expressions, it frees the memory used for the expression. 1781 */ 1782static int |
1673toicon(tnode_t *tn) | 1783toicon(tnode_t *tn, int required) |
1674{ 1675 int i; 1676 tspec_t t; 1677 val_t *v; 1678 | 1784{ 1785 int i; 1786 tspec_t t; 1787 val_t *v; 1788 |
1679 v = constant(tn); | 1789 v = constant(tn, required); |
1680 1681 /* 1682 * Abstract declarations are used inside expression. To free 1683 * the memory would be a fatal error. 1684 */ 1685 if (dcs->d_ctx != ABSTRACT) 1686 tfreeblk(); 1687 --- 28 unchanged lines hidden (view full) --- 1716 1717 initerr = 0; 1718 initsym = decl; 1719 1720 switch (dcs->d_ctx) { 1721 case EXTERN: 1722 if (rename != NULL) { 1723 if (decl->s_rename != NULL) | 1790 1791 /* 1792 * Abstract declarations are used inside expression. To free 1793 * the memory would be a fatal error. 1794 */ 1795 if (dcs->d_ctx != ABSTRACT) 1796 tfreeblk(); 1797 --- 28 unchanged lines hidden (view full) --- 1826 1827 initerr = 0; 1828 initsym = decl; 1829 1830 switch (dcs->d_ctx) { 1831 case EXTERN: 1832 if (rename != NULL) { 1833 if (decl->s_rename != NULL) |
1724 lerror("idecl() 1"); | 1834 LERROR("idecl()"); |
1725 1726 s = getlblk(1, rename->sb_len + 1); 1727 (void)memcpy(s, rename->sb_name, rename->sb_len + 1); 1728 decl->s_rename = s; 1729 freeyyv(&rename, T_NAME); 1730 } 1731 decl1ext(decl, initflg); 1732 break; --- 11 unchanged lines hidden (view full) --- 1744 /* symbol renaming can't be used on automatic variables */ 1745 error(311); 1746 freeyyv(&rename, T_NAME); 1747 break; 1748 } 1749 decl1loc(decl, initflg); 1750 break; 1751 default: | 1835 1836 s = getlblk(1, rename->sb_len + 1); 1837 (void)memcpy(s, rename->sb_name, rename->sb_len + 1); 1838 decl->s_rename = s; 1839 freeyyv(&rename, T_NAME); 1840 } 1841 decl1ext(decl, initflg); 1842 break; --- 11 unchanged lines hidden (view full) --- 1854 /* symbol renaming can't be used on automatic variables */ 1855 error(311); 1856 freeyyv(&rename, T_NAME); 1857 break; 1858 } 1859 decl1loc(decl, initflg); 1860 break; 1861 default: |
1752 lerror("idecl() 2"); | 1862 LERROR("idecl()"); |
1753 } 1754 1755 if (initflg && !initerr) 1756 prepinit(); 1757} 1758 1759/* 1760 * Discard all input tokens up to and including the next --- 23 unchanged lines hidden --- | 1863 } 1864 1865 if (initflg && !initerr) 1866 prepinit(); 1867} 1868 1869/* 1870 * Discard all input tokens up to and including the next --- 23 unchanged lines hidden --- |