c-parser.c (169690) | c-parser.c (260014) |
---|---|
1/* Parser for C and Objective-C. 2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4 5 Parser actions based on the old Bison parser; structure somewhat 6 influenced by and fragments based on the C++ parser. 7 8This file is part of GCC. --- 3926 unchanged lines hidden (view full) --- 3935 add_stmt (build1 (LABEL_EXPR, void_type_node, c_break_label)); 3936 c_break_label = save_break; 3937 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 3938} 3939 3940/* Parse a while statement (C90 6.6.5, C99 6.8.5). 3941 3942 while-statement: | 1/* Parser for C and Objective-C. 2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4 5 Parser actions based on the old Bison parser; structure somewhat 6 influenced by and fragments based on the C++ parser. 7 8This file is part of GCC. --- 3926 unchanged lines hidden (view full) --- 3935 add_stmt (build1 (LABEL_EXPR, void_type_node, c_break_label)); 3936 c_break_label = save_break; 3937 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 3938} 3939 3940/* Parse a while statement (C90 6.6.5, C99 6.8.5). 3941 3942 while-statement: |
3943 while (expression) statement | 3943 APPLE LOCAL begin for-fsf-4_4 3274130 5295549 3944 while attributes (expression) statement 3945 3946 The use of attributes is a GNU extension. 3947 APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
3944*/ 3945 3946static void 3947c_parser_while_statement (c_parser *parser) 3948{ | 3948*/ 3949 3950static void 3951c_parser_while_statement (c_parser *parser) 3952{ |
3949 tree block, cond, body, save_break, save_cont; | 3953/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 3954 tree block, cond, body, save_break, save_cont, attrs; 3955/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
3950 location_t loc; 3951 gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE)); 3952 c_parser_consume_token (parser); | 3956 location_t loc; 3957 gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE)); 3958 c_parser_consume_token (parser); |
3959/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 3960 attrs = c_parser_attributes (parser); 3961/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
|
3953 block = c_begin_compound_stmt (flag_isoc99); 3954 loc = c_parser_peek_token (parser)->location; 3955 cond = c_parser_paren_condition (parser); 3956 save_break = c_break_label; 3957 c_break_label = NULL_TREE; 3958 save_cont = c_cont_label; 3959 c_cont_label = NULL_TREE; 3960 body = c_parser_c99_block_statement (parser); | 3962 block = c_begin_compound_stmt (flag_isoc99); 3963 loc = c_parser_peek_token (parser)->location; 3964 cond = c_parser_paren_condition (parser); 3965 save_break = c_break_label; 3966 c_break_label = NULL_TREE; 3967 save_cont = c_cont_label; 3968 c_cont_label = NULL_TREE; 3969 body = c_parser_c99_block_statement (parser); |
3961 c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true); | 3970/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 3971 c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, attrs, 3972 true); 3973/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
3962 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 3963 c_break_label = save_break; 3964 c_cont_label = save_cont; 3965} 3966 3967/* Parse a do statement (C90 6.6.5, C99 6.8.5). 3968 3969 do-statement: | 3974 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 3975 c_break_label = save_break; 3976 c_cont_label = save_cont; 3977} 3978 3979/* Parse a do statement (C90 6.6.5, C99 6.8.5). 3980 3981 do-statement: |
3970 do statement while ( expression ) ; | 3982 APPLE LOCAL begin for-fsf-4_4 3274130 5295549 3983 do attributes statement while ( expression ) ; 3984 3985 The use of attributes is a GNU extension. 3986 APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
3971*/ 3972 3973static void 3974c_parser_do_statement (c_parser *parser) 3975{ | 3987*/ 3988 3989static void 3990c_parser_do_statement (c_parser *parser) 3991{ |
3976 tree block, cond, body, save_break, save_cont, new_break, new_cont; | 3992/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 3993 tree block, cond, body, save_break, save_cont, new_break, new_cont, attrs; 3994/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
3977 location_t loc; 3978 gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); 3979 c_parser_consume_token (parser); | 3995 location_t loc; 3996 gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); 3997 c_parser_consume_token (parser); |
3998/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 3999 attrs = c_parser_attributes (parser); 4000/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
|
3980 block = c_begin_compound_stmt (flag_isoc99); 3981 loc = c_parser_peek_token (parser)->location; 3982 save_break = c_break_label; 3983 c_break_label = NULL_TREE; 3984 save_cont = c_cont_label; 3985 c_cont_label = NULL_TREE; 3986 body = c_parser_c99_block_statement (parser); 3987 c_parser_require_keyword (parser, RID_WHILE, "expected %<while%>"); 3988 new_break = c_break_label; 3989 c_break_label = save_break; 3990 new_cont = c_cont_label; 3991 c_cont_label = save_cont; 3992 cond = c_parser_paren_condition (parser); 3993 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) 3994 c_parser_skip_to_end_of_block_or_statement (parser); | 4001 block = c_begin_compound_stmt (flag_isoc99); 4002 loc = c_parser_peek_token (parser)->location; 4003 save_break = c_break_label; 4004 c_break_label = NULL_TREE; 4005 save_cont = c_cont_label; 4006 c_cont_label = NULL_TREE; 4007 body = c_parser_c99_block_statement (parser); 4008 c_parser_require_keyword (parser, RID_WHILE, "expected %<while%>"); 4009 new_break = c_break_label; 4010 c_break_label = save_break; 4011 new_cont = c_cont_label; 4012 c_cont_label = save_cont; 4013 cond = c_parser_paren_condition (parser); 4014 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) 4015 c_parser_skip_to_end_of_block_or_statement (parser); |
3995 c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false); | 4016/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 4017 c_finish_loop (loc, cond, NULL, body, new_break, new_cont, attrs, false); 4018/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
3996 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 3997} 3998 3999/* Parse a for statement (C90 6.6.5, C99 6.8.5). 4000 4001 for-statement: | 4019 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 4020} 4021 4022/* Parse a for statement (C90 6.6.5, C99 6.8.5). 4023 4024 for-statement: |
4002 for ( expression[opt] ; expression[opt] ; expression[opt] ) statement 4003 for ( nested-declaration expression[opt] ; expression[opt] ) statement | 4025 APPLE LOCAL begin for-fsf-4_4 3274130 5295549 4026 for attributes ( expression[opt] ; expression[opt] ; expression[opt] ) \ 4027 statement 4028 for attributes ( nested-declaration expression[opt] ; expression[opt] ) \ 4029 statement |
4004 4005 The form with a declaration is new in C99. 4006 | 4030 4031 The form with a declaration is new in C99. 4032 |
4033 The use of attributes is a GNU extension. 4034 4035 APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
4007 ??? In accordance with the old parser, the declaration may be a 4008 nested function, which is then rejected in check_for_loop_decls, 4009 but does it make any sense for this to be included in the grammar? 4010 Note in particular that the nested function does not include a 4011 trailing ';', whereas the "declaration" production includes one. 4012 Also, can we reject bad declarations earlier and cheaper than 4013 check_for_loop_decls? */ 4014 4015static void 4016c_parser_for_statement (c_parser *parser) 4017{ | 4036 ??? In accordance with the old parser, the declaration may be a 4037 nested function, which is then rejected in check_for_loop_decls, 4038 but does it make any sense for this to be included in the grammar? 4039 Note in particular that the nested function does not include a 4040 trailing ';', whereas the "declaration" production includes one. 4041 Also, can we reject bad declarations earlier and cheaper than 4042 check_for_loop_decls? */ 4043 4044static void 4045c_parser_for_statement (c_parser *parser) 4046{ |
4018 tree block, cond, incr, save_break, save_cont, body; | 4047/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 4048 tree block, cond, incr, save_break, save_cont, body, attrs; 4049/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
4019 location_t loc; 4020 gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR)); 4021 loc = c_parser_peek_token (parser)->location; 4022 c_parser_consume_token (parser); | 4050 location_t loc; 4051 gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR)); 4052 loc = c_parser_peek_token (parser)->location; 4053 c_parser_consume_token (parser); |
4054/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 4055 attrs = c_parser_attributes (parser); 4056/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
|
4023 block = c_begin_compound_stmt (flag_isoc99); 4024 if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) 4025 { 4026 /* Parse the initialization declaration or expression. */ 4027 if (c_parser_next_token_is (parser, CPP_SEMICOLON)) 4028 { 4029 c_parser_consume_token (parser); 4030 c_finish_expr_stmt (NULL_TREE); --- 58 unchanged lines hidden (view full) --- 4089 cond = error_mark_node; 4090 incr = error_mark_node; 4091 } 4092 save_break = c_break_label; 4093 c_break_label = NULL_TREE; 4094 save_cont = c_cont_label; 4095 c_cont_label = NULL_TREE; 4096 body = c_parser_c99_block_statement (parser); | 4057 block = c_begin_compound_stmt (flag_isoc99); 4058 if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) 4059 { 4060 /* Parse the initialization declaration or expression. */ 4061 if (c_parser_next_token_is (parser, CPP_SEMICOLON)) 4062 { 4063 c_parser_consume_token (parser); 4064 c_finish_expr_stmt (NULL_TREE); --- 58 unchanged lines hidden (view full) --- 4123 cond = error_mark_node; 4124 incr = error_mark_node; 4125 } 4126 save_break = c_break_label; 4127 c_break_label = NULL_TREE; 4128 save_cont = c_cont_label; 4129 c_cont_label = NULL_TREE; 4130 body = c_parser_c99_block_statement (parser); |
4097 c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true); | 4131/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ 4132 c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, attrs, 4133 true); 4134/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ |
4098 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 4099 c_break_label = save_break; 4100 c_cont_label = save_cont; 4101} 4102 4103/* Parse an asm statement, a GNU extension. This is a full-blown asm 4104 statement with inputs, outputs, clobbers, and volatile tag 4105 allowed. --- 3763 unchanged lines hidden --- | 4135 add_stmt (c_end_compound_stmt (block, flag_isoc99)); 4136 c_break_label = save_break; 4137 c_cont_label = save_cont; 4138} 4139 4140/* Parse an asm statement, a GNU extension. This is a full-blown asm 4141 statement with inputs, outputs, clobbers, and volatile tag 4142 allowed. --- 3763 unchanged lines hidden --- |