Changeset 4cc585b
- Timestamp:
- Aug 20, 2017, 9:26:37 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 5916272
- Parents:
- 274ce8c
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r274ce8c r4cc585b 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 17 15:52:12201713 // Update Count : 2 48912 // Last Modified On : Sun Aug 20 09:21:54 2017 13 // Update Count : 2573 14 14 // 15 15 … … 131 131 %token ATTRIBUTE EXTENSION // GCC 132 132 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH 133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA 134 134 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 135 135 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 801 801 | IF '(' push if_control_expression ')' statement ELSE statement 802 802 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 803 | SWITCH '(' comma_expression ')' case_clause // CFA803 | SWITCH '(' comma_expression ')' case_clause 804 804 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 805 805 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA … … 825 825 comma_expression pop 826 826 { $$ = new IfCtl( nullptr, $1 ); } 827 | c_declaration 827 | c_declaration pop // no semi-colon 828 828 { $$ = new IfCtl( $1, nullptr ); } 829 | cfa_declaration 829 | cfa_declaration pop // no semi-colon 830 830 { $$ = new IfCtl( $1, nullptr ); } 831 831 | declaration comma_expression // semi-colon separated … … 1104 1104 1105 1105 KR_declaration_list_opt: // used to declare parameter types in K&R style functions 1106 pop1106 // empty 1107 1107 { $$ = nullptr; } 1108 1108 | KR_declaration_list … … 1110 1110 1111 1111 KR_declaration_list: 1112 c_declaration ';' 1113 | KR_declaration_list push c_declaration ';' 1112 push c_declaration pop ';' 1113 { $$ = $2; } 1114 | KR_declaration_list push c_declaration pop ';' 1114 1115 { $$ = $1->appendList( $3 ); } 1115 1116 ; … … 1131 1132 1132 1133 declaration: // old & new style declarations 1133 c_declaration ';'1134 | cfa_declaration ';'// CFA1134 c_declaration pop ';' 1135 | cfa_declaration pop ';' // CFA 1135 1136 ; 1136 1137 … … 1147 1148 1148 1149 cfa_declaration: // CFA 1149 cfa_variable_declaration pop1150 | cfa_typedef_declaration pop1151 | cfa_function_declaration pop1152 | type_declaring_list pop1153 | trait_specifier pop1150 cfa_variable_declaration 1151 | cfa_typedef_declaration 1152 | cfa_function_declaration 1153 | type_declaring_list 1154 | trait_specifier 1154 1155 ; 1155 1156 … … 1351 1352 1352 1353 c_declaration: 1353 declaration_specifier declaring_list pop1354 declaration_specifier declaring_list 1354 1355 { 1355 1356 $$ = distAttr( $1, $2 ); 1356 1357 } 1357 | typedef_declaration pop1358 | typedef_expression pop// GCC, naming expression type1359 | sue_declaration_specifier pop1358 | typedef_declaration 1359 | typedef_expression // GCC, naming expression type 1360 | sue_declaration_specifier 1360 1361 ; 1361 1362 … … 2230 2231 $$ = $1->addFunctionBody( $2 ); 2231 2232 } 2232 | KR_function_declarator pushKR_declaration_list_opt compound_statement2233 | KR_function_declarator KR_declaration_list_opt compound_statement 2233 2234 { 2234 2235 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2235 2236 typedefTable.leaveScope(); 2236 $$ = $1->addOldDeclList( $ 3 )->addFunctionBody( $4);2237 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2237 2238 } 2238 2239 ; … … 2278 2279 2279 2280 // Old-style K&R function definition, OBSOLESCENT (see 4) 2280 | declaration_specifier KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2281 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2281 2282 { 2282 2283 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2283 2284 typedefTable.leaveScope(); 2284 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addType( $1 );2285 } 2286 | type_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2285 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addType( $1 ); 2286 } 2287 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2287 2288 { 2288 2289 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2289 2290 typedefTable.leaveScope(); 2290 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addQualifiers( $1 );2291 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2291 2292 } 2292 2293 2293 2294 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) 2294 | declaration_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2295 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2295 2296 { 2296 2297 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2297 2298 typedefTable.leaveScope(); 2298 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addQualifiers( $1 );2299 } 2300 | declaration_qualifier_list type_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2299 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2300 } 2301 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2301 2302 { 2302 2303 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2303 2304 typedefTable.leaveScope(); 2304 $$ = $3->addOldDeclList( $ 5 )->addFunctionBody( $7)->addQualifiers( $2 )->addQualifiers( $1 );2305 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 ); 2305 2306 } 2306 2307 ; -
src/tests/.expect/64/KRfunctions.txt
r274ce8c r4cc585b 79 79 __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)]; 80 80 } 81 int __f15__Fi_iii__1(int __a__i_1, int __b__i_1, int __c__i_1){ 82 __attribute__ ((unused)) int ___retval_f15__i_1; 83 } 81 84 const int __fred__FCi___1(){ 82 85 __attribute__ ((unused)) const int ___retval_fred__Ci_1; -
src/tests/KRfunctions.c
r274ce8c r4cc585b 10 10 // Created On : Thu Feb 16 15:23:17 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 24 22:05:00201713 // Update Count : 312 // Last Modified On : Sun Aug 20 07:34:17 2017 13 // Update Count : 7 14 14 // 15 15 … … 37 37 int ((* f13( a, b, c ))[])[10] int a, * b, c[]; {} 38 38 int (((* f14( a, b, c ))[])[10]) int a, * b, c[]; {} 39 f15( a, b, c ) {} 39 40 40 41 const fred() {
Note: See TracChangeset
for help on using the changeset viewer.