Changeset cd28605
- Timestamp:
- Feb 6, 2025, 3:42:32 PM (7 months ago)
- Branches:
- master
- Children:
- eca364f7
- Parents:
- a8e2215
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cpp
ra8e2215 rcd28605 10 10 // Author : Rodolfo G. Esteves 11 11 // Created On : Sat May 16 14:59:41 2015 12 // Last Modified By : Kyoung Seo13 // Last Modified On : Th d Jan 16 13:05:00202514 // Update Count : 43 312 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Feb 6 11:38:39 2025 14 // Update Count : 434 15 15 // 16 16 … … 70 70 stmt.reset( new ast::DeclStmt( declLocation, maybeMoveBuild( agg ) ) ); 71 71 } // StatementNode::StatementNode 72 73 StatementNode * StatementNode::addQualifiers( DeclarationNode * attr ) { 74 if ( ! attr ) { return this; } // empty attribute list 75 attributes.insert( attributes.end(), attr->attributes.begin(), attr->attributes.end() ); 76 return this; 77 } 72 78 73 79 StatementNode * StatementNode::add_label( -
src/Parser/StatementNode.hpp
ra8e2215 rcd28605 10 10 // Created On : Wed Apr 5 11:42:00 2023 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 23 22:43:05 202413 // Update Count : 312 // Last Modified On : Thu Feb 6 11:39:26 2025 13 // Update Count : 6 14 14 // 15 15 … … 27 27 ast::Stmt * build() { return stmt.release(); } 28 28 29 StatementNode * addQualifiers( DeclarationNode * ); 29 30 StatementNode * add_label( 30 31 const CodeLocation & location, … … 36 37 } 37 38 39 std::vector<ast::ptr<ast::Attribute>> attributes; 38 40 std::unique_ptr<ast::Stmt> stmt; 39 41 }; // StatementNode -
src/Parser/parser.yy
ra8e2215 rcd28605 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 17 14:35:08202513 // Update Count : 693512 // Last Modified On : Thu Feb 6 11:40:06 2025 13 // Update Count : 7236 14 14 // 15 15 … … 54 54 #include "Common/SemanticError.hpp" // error_str 55 55 #include "Common/Utility.hpp" // for maybeMoveBuild, maybeBuild, CodeLo... 56 #include "AST/Attribute.hpp" // for Attribute 57 #include "AST/Print.hpp" // for print 58 #include "Common/Iterate.hpp" // for reverseIterate 56 59 57 60 // lex uses __null in a boolean context, it's fine. … … 98 101 } // appendStr 99 102 100 DeclarationNode * dist Attr( DeclarationNode * typeSpec, DeclarationNode * declList ) {103 DeclarationNode * distTypeSpec( DeclarationNode * typeSpec, DeclarationNode * declList ) { 101 104 // Distribute type specifier across all declared variables, e.g., static, const, __attribute__. 102 105 assert( declList ); … … 132 135 declList->addType( cl, copyattr ); // cl IS DELETED!!! 133 136 return declList; 137 } // distTypeSpec 138 139 void distAttr( DeclarationNode * attributes, DeclarationNode * declaration ) { 140 // distribute attributes across all declaring list 141 for ( DeclarationNode * attr = attributes; attr != nullptr ; attr = attr->next ) { 142 for ( DeclarationNode * decl = declaration ; decl != nullptr ; decl = decl->next ) { 143 decl->attributes.insert( decl->attributes.begin(), attr->attributes.begin(), attr->attributes.end() ); 144 } // for 145 } // for 134 146 } // distAttr 135 147 136 148 void distExt( DeclarationNode * declaration ) { 137 149 // distribute EXTENSION across all declarations 138 for ( DeclarationNode * iter = declaration ; iter != nullptr ; iter = iter->next ) {139 iter->set_extension( true );150 for ( DeclarationNode * decl = declaration ; decl != nullptr ; decl = decl->next ) { 151 decl->set_extension( true ); 140 152 } // for 141 153 } // distExt … … 143 155 void distInl( DeclarationNode * declaration ) { 144 156 // distribute INLINE across all declarations 145 for ( DeclarationNode * iter = declaration ; iter != nullptr ; iter = iter->next ) {146 iter->set_inLine( true );157 for ( DeclarationNode *decl = declaration ; decl != nullptr ; decl = decl->next ) { 158 decl->set_inLine( true ); 147 159 } // for 148 160 } // distInl … … 150 162 void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) { 151 163 // distribute qualifiers across all non-variable declarations in a distribution statemement 152 for ( DeclarationNode * iter = declaration ; iter != nullptr ; iter = iter->next ) {164 for ( DeclarationNode * decl = declaration ; decl != nullptr ; decl = decl->next ) { 153 165 // SKULLDUGGERY: Distributions are parsed inside out, so qualifiers are added to declarations inside out. Since 154 166 // addQualifiers appends to the back of the list, the forall clauses are in the wrong order (right to left). To … … 157 169 DeclarationNode * clone = qualifiers->clone(); 158 170 if ( qualifiers->type ) { // forall clause ? (handles SC) 159 if ( iter->type->kind == TypeData::Aggregate ) { // struct/union ?160 swap( clone->type->forall, iter->type->aggregate.params );161 iter->addQualifiers( clone );162 } else if ( iter->type->kind == TypeData::AggregateInst && iter->type->aggInst.aggregate->aggregate.body ) { // struct/union ?171 if ( decl->type->kind == TypeData::Aggregate ) { // struct/union ? 172 swap( clone->type->forall, decl->type->aggregate.params ); 173 decl->addQualifiers( clone ); 174 } else if ( decl->type->kind == TypeData::AggregateInst && decl->type->aggInst.aggregate->aggregate.body ) { // struct/union ? 163 175 // Create temporary node to hold aggregate, call addQualifiers as above, then put nodes back together. 164 176 DeclarationNode newnode; 165 swap( newnode.type, iter->type->aggInst.aggregate );177 swap( newnode.type, decl->type->aggInst.aggregate ); 166 178 swap( clone->type->forall, newnode.type->aggregate.params ); 167 179 newnode.addQualifiers( clone ); 168 swap( newnode.type, iter->type->aggInst.aggregate );169 } else if ( iter->type->kind == TypeData::Function ) { // routines ?170 swap( clone->type->forall, iter->type->forall );171 iter->addQualifiers( clone );180 swap( newnode.type, decl->type->aggInst.aggregate ); 181 } else if ( decl->type->kind == TypeData::Function ) { // routines ? 182 swap( clone->type->forall, decl->type->forall ); 183 decl->addQualifiers( clone ); 172 184 } // if 173 185 } else { // just SC qualifiers 174 iter->addQualifiers( clone );186 decl->addQualifiers( clone ); 175 187 } // if 176 188 } // for … … 210 222 211 223 // printf( "fieldDecl3 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout, 0 ); 212 DeclarationNode * temp = dist Attr( typeSpec, fieldList ); // mark all fields in list224 DeclarationNode * temp = distTypeSpec( typeSpec, fieldList ); // mark all fields in list 213 225 // printf( "fieldDecl4 temp %p\n", temp ); temp->print( std::cout, 0 ); 214 226 return temp; … … 253 265 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicKind::SignedInt ) ) ); 254 266 } // if 255 DeclarationNode * initDecl = dist Attr(267 DeclarationNode * initDecl = distTypeSpec( 256 268 DeclarationNode::newTypeof( type, true ), 257 269 DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) … … 434 446 %type<decl> asm_name_opt 435 447 %type<expr> asm_operands_opt asm_operands_list asm_operand 436 %type<labels> label_list448 %type<labels> asm_label_list 437 449 %type<expr> asm_clobbers_list_opt 438 450 %type<is_volatile> asm_volatile_opt … … 441 453 442 454 // statements 443 %type<stmt> statement label ed_statement compound_statement455 %type<stmt> statement labelled_statement compound_statement 444 456 %type<stmt> statement_decl statement_decl_list statement_list_nodecl 445 457 %type<stmt> selection_statement … … 926 938 | SIZEOF '(' type_no_function ')' 927 939 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 940 | SIZEOF '(' attribute_list type_no_function ')' 941 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $4->addQualifiers( $3 ) ) ) ); } 928 942 | ALIGNOF unary_expression // GCC, variable alignment 929 943 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, new ast::TypeofType( maybeMoveBuild( $2 ) ) ) ); } … … 1202 1216 1203 1217 statement: 1204 label ed_statement1218 labelled_statement 1205 1219 | compound_statement 1206 1220 | expression_statement … … 1220 1234 | DIRECTIVE 1221 1235 { $$ = new StatementNode( build_directive( yylloc, $1 ) ); } 1222 // | attribute ';' 1223 // { $$ = new StatementNode( $1 ); } 1224 ; 1225 1226 labeled_statement: 1236 ; 1237 1238 labelled_statement: 1227 1239 // labels cannot be identifiers 0 or 1 1228 1240 identifier_or_type_name ':' attribute_list_opt statement … … 1254 1266 1255 1267 statement_decl: 1256 declaration // CFA, new & old style declarations 1257 { $$ = new StatementNode( $1 ); } 1258 | EXTENSION declaration // GCC 1259 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1260 | function_definition 1261 { $$ = new StatementNode( $1 ); } 1262 | EXTENSION function_definition // GCC 1263 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1264 | statement 1268 attribute_list_opt declaration // CFA, new & old style declarations 1269 { distAttr( $1, $2 ); $$ = new StatementNode( $2 ); } 1270 | attribute_list_opt EXTENSION declaration // GCC 1271 { distAttr( $1, $3 ); distExt( $3 ); $$ = new StatementNode( $3 ); } 1272 | attribute_list_opt function_definition 1273 { distAttr( $1, $2 ); $$ = new StatementNode( $2 ); } 1274 | attribute_list_opt EXTENSION function_definition // GCC 1275 { distAttr( $1, $3 ); distExt( $3 ); $$ = new StatementNode( $3 ); } 1276 | attribute_list_opt statement // FIX ME! 1277 { $$ = $2->addQualifiers( $1 ); } 1265 1278 ; 1266 1279 1267 1280 statement_list_nodecl: 1268 statement 1269 | statement_list_nodecl statement 1270 { assert( $1 ); $1->set_last( $2 ); $$ = $1; } 1281 attribute_list_opt statement 1282 { $$ = $2->addQualifiers( $1 ); } // FIX ME! 1283 | statement_list_nodecl attribute_list_opt statement 1284 { assert( $1 ); $1->set_last( $3->addQualifiers( $2 ) ); $$ = $1; } // FIX ME! 1271 1285 | statement_list_nodecl error // invalid syntax rule 1272 1286 { SemanticError( yylloc, "illegal syntax, declarations only allowed at the start of the switch body," … … 1274 1288 ; 1275 1289 1276 expression_statement: 1290 expression_statement: // expression or null statement 1277 1291 comma_expression_opt ';' 1278 1292 { $$ = new StatementNode( build_expr( yylloc, $1 ) ); } … … 1903 1917 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 1904 1918 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8, $10 ) ); } 1905 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'1919 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' asm_label_list ')' ';' 1906 1920 { $$ = new StatementNode( build_asm( yylloc, $2, $5, nullptr, $8, $10, $12 ) ); } 1907 1921 ; … … 1945 1959 ; 1946 1960 1947 label_list: 1948 identifier 1949 { 1950 $$ = new LabelNode(); $$->labels.emplace_back( yylloc, *$1 ); 1951 delete $1; // allocated by lexer 1952 } 1953 | label_list ',' identifier 1954 { 1955 $$ = $1; $1->labels.emplace_back( yylloc, *$3 ); 1956 delete $3; // allocated by lexer 1957 } 1961 asm_label_list: 1962 identifier_or_type_name 1963 { $$ = new LabelNode(); $$->labels.emplace_back( yylloc, *$1 ); delete $1; } // allocated by lexer 1964 | asm_label_list ',' identifier_or_type_name 1965 { $$ = $1; $1->labels.emplace_back( yylloc, *$3 ); delete $3; } // allocated by lexer 1958 1966 ; 1959 1967 … … 1967 1975 1968 1976 declaration_list: 1969 declaration 1977 attribute_list_opt declaration 1978 { $$ = $2->addQualifiers( $1 ); } 1970 1979 | declaration_list declaration 1971 1980 { $$ = $1->set_last( $2 ); } … … 2142 2151 } else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3 2143 2152 } 2153 | TYPEDEF attribute_list type_specifier declarator 2154 { 2155 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "typedef_declaration 1" ); 2156 if ( $3->type->forall || ($3->type->kind == TypeData::Aggregate && $3->type->aggregate.params) ) { 2157 SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr; 2158 } else $$ = $4->addType( $3 )->addTypedef()->addQualifiers( $2 ); // watchout frees $3 and $4 2159 } 2144 2160 | typedef_declaration ',' declarator 2145 2161 { … … 2169 2185 c_declaration: 2170 2186 declaration_specifier declaring_list 2171 { $$ = dist Attr( $1, $2 ); }2187 { $$ = distTypeSpec( $1, $2 ); } 2172 2188 | typedef_declaration 2173 2189 | typedef_expression // deprecated GCC, naming expression type … … 2265 2281 // specifier-qualifier-list, either directly or via one or more typedefs, the behavior is the same as if it 2266 2282 // appeared only once. 2267 type_qualifier 2268 | type_qualifier_list type_qualifier 2283 type_qualifier attribute_list_opt 2269 2284 { $$ = $1->addQualifiers( $2 ); } 2285 | type_qualifier_list type_qualifier attribute_list_opt 2286 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 2270 2287 ; 2271 2288 … … 2273 2290 type_qualifier_name 2274 2291 { $$ = DeclarationNode::newFromTypeData( $1 ); } 2275 | attribute // trick handles most attribute locations2276 2292 ; 2277 2293 … … 2301 2317 declaration_qualifier_list: 2302 2318 storage_class_list 2303 | type_qualifier_list storage_class_list // remaining OBSOLESCENT (see 2 )2319 | type_qualifier_list storage_class_list 2304 2320 { $$ = $1->addQualifiers( $2 ); } 2305 2321 | declaration_qualifier_list type_qualifier_list storage_class_list … … 2313 2329 // ISO/IEC 9899:1999 Section 6.7.1(2) : At most, one storage-class specifier may be given in the declaration 2314 2330 // specifiers in a declaration. 2315 storage_class 2316 | storage_class_list storage_class 2331 storage_class attribute_list_opt 2317 2332 { $$ = $1->addQualifiers( $2 ); } 2333 | storage_class_list storage_class attribute_list_opt 2334 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 2318 2335 ; 2319 2336 … … 2440 2457 | declaration_qualifier_list basic_type_specifier 2441 2458 { $$ = $2->addQualifiers( $1 ); } 2442 | basic_declaration_specifier storage_class 2443 { $$ = $1->addQualifiers( $2 ) ; }2459 | basic_declaration_specifier storage_class attribute_list_opt // remaining OBSOLESCENT (see 2) 2460 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 2444 2461 | basic_declaration_specifier storage_class type_qualifier_list 2445 2462 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } … … 2449 2466 2450 2467 basic_type_specifier: 2451 direct_type 2468 direct_type attribute_list_opt 2469 { $$ = $1->addQualifiers( $2 ); } 2452 2470 // Cannot have type modifiers, e.g., short, long, etc. 2471 | type_qualifier_list_opt indirect_type attribute_list 2472 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 2453 2473 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 2454 2474 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } … … 2522 2542 2523 2543 type_declaration_specifier: 2524 type_type_specifier 2525 | declaration_qualifier_list type_type_specifier 2526 { $$ = $2->addQualifiers( $1 ); } 2527 | type_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 2544 type_type_specifier attribute_list_opt 2528 2545 { $$ = $1->addQualifiers( $2 ); } 2546 | declaration_qualifier_list type_type_specifier attribute_list_opt 2547 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 2548 | type_declaration_specifier storage_class attribute_list_opt // remaining OBSOLESCENT (see 2) 2549 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 2529 2550 | type_declaration_specifier storage_class type_qualifier_list 2530 2551 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } … … 2578 2599 aggregate_key attribute_list_opt 2579 2600 { forall = false; } // reset 2580 '{' field_declaration_list_opt '}' type_parameters_opt 2581 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ) ; }2582 | aggregate_key attribute_list_opt identifier 2601 '{' field_declaration_list_opt '}' type_parameters_opt attribute_list_opt 2602 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 )->addQualifiers( $8 ); } 2603 | aggregate_key attribute_list_opt identifier attribute_list_opt 2583 2604 { 2584 2605 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 1" ); 2585 2606 forall = false; // reset 2586 2607 } 2587 '{' field_declaration_list_opt '}' type_parameters_opt 2588 { 2589 $$ = DeclarationNode::newAggregate( $1, $3, $ 8, $6, true )->addQualifiers( $2);2590 } 2591 | aggregate_key attribute_list_opt TYPEDEFname 2608 '{' field_declaration_list_opt '}' type_parameters_opt attribute_list_opt 2609 { 2610 $$ = DeclarationNode::newAggregate( $1, $3, $9, $7, true )->addQualifiers( $2 )->addQualifiers( $4 )->addQualifiers( $10 ); 2611 } 2612 | aggregate_key attribute_list_opt TYPEDEFname attribute_list_opt // unqualified type name 2592 2613 { 2593 2614 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 2" ); 2594 2615 forall = false; // reset 2595 2616 } 2596 '{' field_declaration_list_opt '}' type_parameters_opt 2617 '{' field_declaration_list_opt '}' type_parameters_opt attribute_list_opt 2597 2618 { 2598 2619 DeclarationNode::newFromTypeData( build_typedef( $3 ) ); 2599 $$ = DeclarationNode::newAggregate( $1, $3, $ 8, $6, true )->addQualifiers( $2);2600 } 2601 | aggregate_key attribute_list_opt TYPEGENname 2620 $$ = DeclarationNode::newAggregate( $1, $3, $9, $7, true )->addQualifiers( $2 )->addQualifiers( $4 )->addQualifiers( $10 ); 2621 } 2622 | aggregate_key attribute_list_opt TYPEGENname attribute_list_opt // unqualified type name 2602 2623 { 2603 2624 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 3" ); 2604 2625 forall = false; // reset 2605 2626 } 2606 '{' field_declaration_list_opt '}' type_parameters_opt 2627 '{' field_declaration_list_opt '}' type_parameters_opt attribute_list_opt 2607 2628 { 2608 2629 DeclarationNode::newFromTypeData( build_type_gen( $3, nullptr ) ); 2609 $$ = DeclarationNode::newAggregate( $1, $3, $ 8, $6, true )->addQualifiers( $2);2630 $$ = DeclarationNode::newAggregate( $1, $3, $9, $7, true )->addQualifiers( $2 )->addQualifiers( $10 ); 2610 2631 } 2611 2632 | aggregate_type_nobody … … 2686 2707 2687 2708 field_declaration_list_opt: 2688 // empty 2709 // empty => struct S { /* no fields */ }; 2689 2710 { $$ = nullptr; } 2690 | field_declaration_list_opt field_declaration2691 { $$ = $1 ? $1->set_last( $2 ) : $2; }2711 | field_declaration_list_opt attribute_list_opt field_declaration 2712 { distAttr( $2, $3 ); $$ = $1 ? $1->set_last( $3 ) : $3; } 2692 2713 ; 2693 2714 2694 2715 field_declaration: 2695 2716 type_specifier field_declaring_list_opt ';' 2696 { 2697 $$ = fieldDecl( $1, $2 ); 2698 } 2717 { $$ = fieldDecl( $1, $2 ); } 2699 2718 | type_specifier field_declaring_list_opt '}' // invalid syntax rule 2700 2719 { … … 2706 2725 | STATIC type_specifier field_declaring_list_opt ';' // CFA 2707 2726 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; } 2708 | INLINE type_specifier field_abstract_list_opt ';' // CFA2709 { 2710 if ( ! $ 3) { // field declarator ?2711 $ 3= DeclarationNode::newName( nullptr );2727 | INLINE attribute_list_opt type_specifier field_abstract_list_opt ';' // CFA 2728 { 2729 if ( ! $4 ) { // field declarator ? 2730 $4 = DeclarationNode::newName( nullptr ); 2712 2731 } // if 2713 $ 3->inLine = true;2714 $$ = dist Attr( $2, $3 );// mark all fields in list2715 distInl( $ 3);2716 } 2717 | INLINE a ggregate_control ';' // CFA2732 $4->inLine = true; 2733 $$ = distTypeSpec( $3, $4 ); // mark all fields in list 2734 distInl( $4 ); 2735 } 2736 | INLINE attribute_list_opt aggregate_control ';' // CFA 2718 2737 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; } 2719 2738 | typedef_declaration ';' // CFA … … 2721 2740 | EXTENSION cfa_field_declaring_list ';' // GCC 2722 2741 { distExt( $2 ); $$ = $2; } // mark all fields in list 2723 | INLINE cfa_field_abstract_list ';'// CFA, new style field declaration2724 { $$ = $ 2; }// mark all fields in list2742 | INLINE attribute_list_opt cfa_field_abstract_list ';' // CFA, new style field declaration 2743 { $$ = $3->addQualifiers( $2 ); } // mark all fields in list 2725 2744 | cfa_typedef_declaration ';' // CFA 2726 2745 | static_assert ';' // C11 … … 2762 2781 2763 2782 field_abstract: 2764 // no bit fields 2765 variable_abstract_declarator 2783 variable_abstract_declarator // no bit fields 2766 2784 ; 2767 2785 … … 2796 2814 enum_type: 2797 2815 // anonymous, no type name 2798 ENUM attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' 2816 ENUM attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt 2799 2817 { 2800 2818 if ( $3 == EnumHiding::Hide ) { 2801 2819 SemanticError( yylloc, "illegal syntax, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; 2802 2820 } // if 2803 $$ = DeclarationNode::newEnum( nullptr, $5, true, false )->addQualifiers( $2 ) ;2804 } 2805 | ENUM enumerator_type attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' 2821 $$ = DeclarationNode::newEnum( nullptr, $5, true, false )->addQualifiers( $2 )->addQualifiers( $8 ); 2822 } 2823 | ENUM enumerator_type attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt 2806 2824 { 2807 2825 if ( $2 && ($2->storageClasses.val != 0 || $2->type->qualifiers.any()) ) { … … 2811 2829 SemanticError( yylloc, "illegal syntax, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; 2812 2830 } // if 2813 $$ = DeclarationNode::newEnum( nullptr, $6, true, true, $2 )->addQualifiers( $3 ) ;2831 $$ = DeclarationNode::newEnum( nullptr, $6, true, true, $2 )->addQualifiers( $3 )->addQualifiers( $9 ); 2814 2832 } 2815 2833 2816 2834 // named type 2817 | ENUM attribute_list_opt identifier 2835 | ENUM attribute_list_opt identifier attribute_list_opt 2818 2836 { typedefTable.makeTypedef( *$3, "enum_type 1" ); } 2819 hide_opt '{' enumerator_list comma_opt '}' 2820 { $$ = DeclarationNode::newEnum( $3, $ 7, true, false, nullptr, $5 )->addQualifiers( $2); }2821 | ENUM attribute_list_opt typedef_name hide_opt '{' enumerator_list comma_opt '}'// unqualified type name2822 { $$ = DeclarationNode::newEnum( $3->name, $ 6, true, false, nullptr, $4 )->addQualifiers( $2); }2837 hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt 2838 { $$ = DeclarationNode::newEnum( $3, $8, true, false, nullptr, $6 )->addQualifiers( $2 ->addQualifiers( $4 ))->addQualifiers( $11 ); } 2839 | ENUM attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt // unqualified type name 2840 { $$ = DeclarationNode::newEnum( $3->name, $7, true, false, nullptr, $5 )->addQualifiers( $2 )->addQualifiers( $4 )->addQualifiers( $10 ); } 2823 2841 | ENUM enumerator_type attribute_list_opt identifier attribute_list_opt 2824 2842 { … … 2828 2846 typedefTable.makeTypedef( *$4, "enum_type 2" ); 2829 2847 } 2830 hide_opt '{' enumerator_list comma_opt '}' 2831 { $$ = DeclarationNode::newEnum( $4, $9, true, true, $2, $7 )->addQualifiers( $3 )->addQualifiers( $5 ) ; }2832 | ENUM enumerator_type attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' 2833 { $$ = DeclarationNode::newEnum( $4->name, $8, true, true, $2, $6 )->addQualifiers( $3 )->addQualifiers( $5 ) ; }2848 hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt 2849 { $$ = DeclarationNode::newEnum( $4, $9, true, true, $2, $7 )->addQualifiers( $3 )->addQualifiers( $5 )->addQualifiers( $12 ); } 2850 | ENUM enumerator_type attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' attribute_list_opt 2851 { $$ = DeclarationNode::newEnum( $4->name, $8, true, true, $2, $6 )->addQualifiers( $3 )->addQualifiers( $5 )->addQualifiers( $11 ); } 2834 2852 2835 2853 // forward declaration … … 2910 2928 parameter_list: // abstract + real 2911 2929 parameter_declaration 2930 | attribute_list parameter_declaration 2931 { $$ = $2->addQualifiers( $1 ); } 2912 2932 | abstract_parameter_declaration 2913 | parameter_list ',' parameter_declaration 2914 { $$ = $1->set_last( $3 ); } 2915 | parameter_list ',' abstract_parameter_declaration 2916 { $$ = $1->set_last( $3 ); } 2933 | attribute_list abstract_parameter_declaration 2934 { $$ = $2->addQualifiers( $1 ); } 2935 | parameter_list ',' attribute_list_opt parameter_declaration 2936 { $4->addQualifiers( $3 ); $$ = $1->set_last( $4 ); } 2937 | parameter_list ',' attribute_list_opt abstract_parameter_declaration 2938 { $4->addQualifiers( $3 ); $$ = $1->set_last( $4 ); } 2917 2939 ; 2918 2940 … … 3002 3024 3003 3025 type_no_function: // sizeof, alignof, cast (constructor) 3004 cfa_abstract_declarator_tuple // CFA 3005 | type_specifier // cannot be type_specifier_nobody, e.g., (struct S {}){} is a thing 3026 type_specifier // cannot be type_specifier_nobody, e.g., (struct S {}){} is a thing 3006 3027 | type_specifier abstract_declarator 3007 3028 { $$ = $2->addType( $1 ); } 3029 | cfa_abstract_declarator_tuple // CFA 3008 3030 ; 3009 3031 3010 3032 type: // typeof, assertion 3011 3033 type_no_function 3034 | attribute_list type_no_function 3035 { $$ = $2->addQualifiers( $1 ); } 3012 3036 | cfa_abstract_function // CFA 3037 | attribute_list cfa_abstract_function // CFA 3038 { $$ = $2->addQualifiers( $1 ); } 3013 3039 ; 3014 3040 … … 3268 3294 ; 3269 3295 3270 external_definition_list:3271 push external_definition pop3272 { $$ = $2; }3273 | external_definition_list push external_definition pop3274 { $$ = $1 ? $1->set_last( $3 ) : $3; }3275 ;3276 3277 3296 external_definition_list_opt: 3278 3297 // empty 3279 3298 { $$ = nullptr; } 3280 3299 | external_definition_list 3300 ; 3301 3302 external_definition_list: 3303 attribute_list_opt push external_definition pop 3304 { distAttr( $1, $3 ); $$ = $3; } 3305 | external_definition_list attribute_list_opt push external_definition pop 3306 { distAttr( $2, $4 ); $$ = $1 ? $1->set_last( $4 ) : $4->addQualifiers( $2 ); } 3281 3307 ; 3282 3308 … … 3587 3613 ptrref_operator variable_declarator 3588 3614 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3615 | ptrref_operator attribute_list variable_declarator 3616 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3589 3617 | ptrref_operator type_qualifier_list variable_declarator 3590 3618 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3651 3679 ptrref_operator function_declarator 3652 3680 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3681 | ptrref_operator attribute_list function_declarator 3682 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3653 3683 | ptrref_operator type_qualifier_list function_declarator 3654 3684 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3703 3733 ptrref_operator KR_function_declarator 3704 3734 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3735 | ptrref_operator attribute_list KR_function_declarator 3736 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3705 3737 | ptrref_operator type_qualifier_list KR_function_declarator 3706 3738 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3756 3788 ptrref_operator variable_type_redeclarator 3757 3789 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3790 | ptrref_operator attribute_list variable_type_redeclarator 3791 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3758 3792 | ptrref_operator type_qualifier_list variable_type_redeclarator 3759 3793 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3820 3854 ptrref_operator function_type_redeclarator 3821 3855 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3856 | ptrref_operator attribute_list function_type_redeclarator 3857 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3822 3858 | ptrref_operator type_qualifier_list function_type_redeclarator 3823 3859 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3864 3900 ptrref_operator identifier_parameter_declarator 3865 3901 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3902 | ptrref_operator attribute_list identifier_parameter_declarator 3903 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3866 3904 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3867 3905 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3922 3960 ptrref_operator type_parameter_redeclarator 3923 3961 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3962 | ptrref_operator attribute_list type_parameter_redeclarator 3963 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 3924 3964 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3925 3965 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3963 4003 3964 4004 abstract_ptr: 3965 ptrref_operator 3966 { $$ = DeclarationNode::newPointer( nullptr, $1 ) ; }4005 ptrref_operator attribute_list_opt 4006 { $$ = DeclarationNode::newPointer( nullptr, $1 )->addQualifiers( $2 ); } 3967 4007 | ptrref_operator type_qualifier_list 3968 4008 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3969 4009 | ptrref_operator abstract_declarator 3970 4010 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 4011 | ptrref_operator attribute_list abstract_declarator 4012 { $$ = $3->addPointer( DeclarationNode::newPointer( nullptr, $1 )->addQualifiers( $2 ) ); } 3971 4013 | ptrref_operator type_qualifier_list abstract_declarator 3972 4014 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 4096 4138 4097 4139 abstract_parameter_ptr: 4098 ptrref_operator 4099 { $$ = DeclarationNode::newPointer( nullptr, $1 ) ; }4140 ptrref_operator attribute_list_opt 4141 { $$ = DeclarationNode::newPointer( nullptr, $1 )->addQualifiers( $2 ); } 4100 4142 | ptrref_operator type_qualifier_list 4101 4143 { $$ = DeclarationNode::newPointer( $2, $1 ); } … … 4175 4217 4176 4218 variable_abstract_ptr: 4177 ptrref_operator 4178 { $$ = DeclarationNode::newPointer( nullptr, $1 ) ; }4219 ptrref_operator attribute_list_opt 4220 { $$ = DeclarationNode::newPointer( nullptr, $1 )->addQualifiers( $2 ); } 4179 4221 | ptrref_operator type_qualifier_list 4180 4222 { $$ = DeclarationNode::newPointer( $2, $1 ); } … … 4223 4265 cfa_identifier_parameter_ptr: // CFA 4224 4266 // No SUE declaration in parameter list. 4225 ptrref_operator type_specifier_nobody4267 ptrref_operator type_specifier_nobody 4226 4268 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 4269 | ptrref_operator attribute_list type_specifier_nobody 4270 { $$ = $3->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 4227 4271 | type_qualifier_list ptrref_operator type_specifier_nobody 4228 4272 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 4323 4367 ptrref_operator type_specifier 4324 4368 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 4369 | ptrref_operator attribute_list type_specifier 4370 { $$ = $3->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) )->addQualifiers( $2 ); } 4325 4371 | type_qualifier_list ptrref_operator type_specifier 4326 4372 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } -
tests/.expect/attributes.x64.txt
ra8e2215 rcd28605 97 97 __attribute__ ((used,used,unused)) signed int _X2f8i_1; 98 98 __attribute__ ((unused)) signed int *_X2f9Pi_1; 99 __attribute__ ((u nused,used)) signed int *_X3f10Pi_1;99 __attribute__ ((used,unused)) signed int *_X3f10Pi_1; 100 100 __attribute__ ((unused,unused)) signed int *_X3f11Pi_1; 101 101 __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1; 102 102 __attribute__ ((unused,unused,unused)) signed int *_X3f13Pi_1; 103 103 __attribute__ ((unused,unused,unused)) signed int *_X3f14Pi_1; 104 __attribute__ ((used)) signed short int _X4shi3s_1; 105 __attribute__ ((used,used)) signed short int _X4shi4s_1; 104 106 }; 105 107 static inline void _X12_constructorFv_S3Fdl_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1){ … … 160 162 } 161 163 164 { 165 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 166 } 167 168 { 169 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 170 } 171 162 172 } 163 173 static inline void _X12_constructorFv_S3FdlS3Fdl_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) struct Fdl _X4_srcS3Fdl_1){ … … 218 228 } 219 229 230 { 231 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1=_X4_srcS3Fdl_1._X4shi3s_1) /* ?{} */); 232 } 233 234 { 235 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1=_X4_srcS3Fdl_1._X4shi4s_1) /* ?{} */); 236 } 237 220 238 } 221 239 static inline void _X11_destructorFv_S3Fdl_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1){ 240 { 241 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ^?{} */); 242 } 243 244 { 245 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ^?{} */); 246 } 247 222 248 { 223 249 ((void)((*_X4_dstS3Fdl_1)._X3f14Pi_1) /* ^?{} */); … … 336 362 337 363 { 364 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1=_X4_srcS3Fdl_1._X4shi3s_1)); 365 } 366 367 { 368 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1=_X4_srcS3Fdl_1._X4shi4s_1)); 369 } 370 371 { 338 372 ((void)_X12_constructorFv_S3FdlS3Fdl_autogen___1((&_X4_retS3Fdl_1), (*_X4_dstS3Fdl_1))); 339 373 } … … 398 432 } 399 433 434 { 435 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 436 } 437 438 { 439 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 440 } 441 400 442 } 401 443 static inline void _X12_constructorFv_S3Fdlii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1){ … … 456 498 } 457 499 500 { 501 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 502 } 503 504 { 505 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 506 } 507 458 508 } 459 509 static inline void _X12_constructorFv_S3Fdliii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1){ … … 514 564 } 515 565 566 { 567 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 568 } 569 570 { 571 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 572 } 573 516 574 } 517 575 static inline void _X12_constructorFv_S3Fdliiii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1){ … … 572 630 } 573 631 632 { 633 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 634 } 635 636 { 637 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 638 } 639 574 640 } 575 641 static inline void _X12_constructorFv_S3Fdliiiii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1){ … … 630 696 } 631 697 698 { 699 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 700 } 701 702 { 703 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 704 } 705 632 706 } 633 707 static inline void _X12_constructorFv_S3Fdliiiiii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1){ … … 688 762 } 689 763 764 { 765 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 766 } 767 768 { 769 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 770 } 771 690 772 } 691 773 static inline void _X12_constructorFv_S3Fdliiiiiii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1){ … … 746 828 } 747 829 830 { 831 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 832 } 833 834 { 835 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 836 } 837 748 838 } 749 839 static inline void _X12_constructorFv_S3Fdliiiiiiii_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1){ … … 804 894 } 805 895 896 { 897 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 898 } 899 900 { 901 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 902 } 903 806 904 } 807 905 static inline void _X12_constructorFv_S3FdliiiiiiiiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1){ … … 862 960 } 863 961 962 { 963 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 964 } 965 966 { 967 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 968 } 969 864 970 } 865 971 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1){ … … 920 1026 } 921 1027 1028 { 1029 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 1030 } 1031 1032 { 1033 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1034 } 1035 922 1036 } 923 1037 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1){ … … 978 1092 } 979 1093 1094 { 1095 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 1096 } 1097 1098 { 1099 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1100 } 1101 980 1102 } 981 1103 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1){ … … 1036 1158 } 1037 1159 1160 { 1161 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 1162 } 1163 1164 { 1165 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1166 } 1167 1038 1168 } 1039 1169 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPiPiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f13Pi_1){ … … 1094 1224 } 1095 1225 1226 { 1227 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 1228 } 1229 1230 { 1231 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1232 } 1233 1096 1234 } 1097 1235 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPiPiPiPi_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f13Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f14Pi_1){ … … 1150 1288 { 1151 1289 ((void)((*_X4_dstS3Fdl_1)._X3f14Pi_1=_X3f14Pi_1) /* ?{} */); 1290 } 1291 1292 { 1293 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1) /* ?{} */); 1294 } 1295 1296 { 1297 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1298 } 1299 1300 } 1301 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPiPiPiPis_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f13Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f14Pi_1, signed short int _X4shi3s_1){ 1302 { 1303 ((void)((*_X4_dstS3Fdl_1)._X2f1i_1=_X2f1i_1) /* ?{} */); 1304 } 1305 1306 { 1307 ((void)((*_X4_dstS3Fdl_1)._X2f2i_1=_X2f2i_1) /* ?{} */); 1308 } 1309 1310 { 1311 ((void)((*_X4_dstS3Fdl_1)._X2f3i_1=_X2f3i_1) /* ?{} */); 1312 } 1313 1314 { 1315 ((void)((*_X4_dstS3Fdl_1)._X2f4i_1=_X2f4i_1) /* ?{} */); 1316 } 1317 1318 { 1319 ((void)((*_X4_dstS3Fdl_1)._X2f5i_1=_X2f5i_1) /* ?{} */); 1320 } 1321 1322 { 1323 ((void)((*_X4_dstS3Fdl_1)._X2f6i_1=_X2f6i_1) /* ?{} */); 1324 } 1325 1326 { 1327 ((void)((*_X4_dstS3Fdl_1)._X2f7i_1=_X2f7i_1) /* ?{} */); 1328 } 1329 1330 { 1331 ((void)((*_X4_dstS3Fdl_1)._X2f8i_1=_X2f8i_1) /* ?{} */); 1332 } 1333 1334 { 1335 ((void)((*_X4_dstS3Fdl_1)._X2f9Pi_1=_X2f9Pi_1) /* ?{} */); 1336 } 1337 1338 { 1339 ((void)((*_X4_dstS3Fdl_1)._X3f10Pi_1=_X3f10Pi_1) /* ?{} */); 1340 } 1341 1342 { 1343 ((void)((*_X4_dstS3Fdl_1)._X3f11Pi_1=_X3f11Pi_1) /* ?{} */); 1344 } 1345 1346 { 1347 ((void)((*_X4_dstS3Fdl_1)._X3f12Pi_1=_X3f12Pi_1) /* ?{} */); 1348 } 1349 1350 { 1351 ((void)((*_X4_dstS3Fdl_1)._X3f13Pi_1=_X3f13Pi_1) /* ?{} */); 1352 } 1353 1354 { 1355 ((void)((*_X4_dstS3Fdl_1)._X3f14Pi_1=_X3f14Pi_1) /* ?{} */); 1356 } 1357 1358 { 1359 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1=_X4shi3s_1) /* ?{} */); 1360 } 1361 1362 { 1363 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1) /* ?{} */); 1364 } 1365 1366 } 1367 static inline void _X12_constructorFv_S3FdliiiiiiiiPiPiPiPiPiPiss_autogen___1(__attribute__ ((unused)) struct Fdl *_X4_dstS3Fdl_1, __attribute__ ((unused)) signed int _X2f1i_1, __attribute__ ((unused)) signed int _X2f2i_1, __attribute__ ((unused,unused)) signed int _X2f3i_1, __attribute__ ((unused)) signed int _X2f4i_1, __attribute__ ((unused,unused)) signed int _X2f5i_1, signed int _X2f6i_1, __attribute__ ((unused,unused)) signed int _X2f7i_1, __attribute__ ((unused)) signed int _X2f8i_1, __attribute__ ((unused)) signed int *_X2f9Pi_1, __attribute__ ((unused)) signed int *_X3f10Pi_1, __attribute__ ((unused,unused)) signed int *_X3f11Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f12Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f13Pi_1, __attribute__ ((unused,unused,unused)) signed int *_X3f14Pi_1, signed short int _X4shi3s_1, signed short int _X4shi4s_1){ 1368 { 1369 ((void)((*_X4_dstS3Fdl_1)._X2f1i_1=_X2f1i_1) /* ?{} */); 1370 } 1371 1372 { 1373 ((void)((*_X4_dstS3Fdl_1)._X2f2i_1=_X2f2i_1) /* ?{} */); 1374 } 1375 1376 { 1377 ((void)((*_X4_dstS3Fdl_1)._X2f3i_1=_X2f3i_1) /* ?{} */); 1378 } 1379 1380 { 1381 ((void)((*_X4_dstS3Fdl_1)._X2f4i_1=_X2f4i_1) /* ?{} */); 1382 } 1383 1384 { 1385 ((void)((*_X4_dstS3Fdl_1)._X2f5i_1=_X2f5i_1) /* ?{} */); 1386 } 1387 1388 { 1389 ((void)((*_X4_dstS3Fdl_1)._X2f6i_1=_X2f6i_1) /* ?{} */); 1390 } 1391 1392 { 1393 ((void)((*_X4_dstS3Fdl_1)._X2f7i_1=_X2f7i_1) /* ?{} */); 1394 } 1395 1396 { 1397 ((void)((*_X4_dstS3Fdl_1)._X2f8i_1=_X2f8i_1) /* ?{} */); 1398 } 1399 1400 { 1401 ((void)((*_X4_dstS3Fdl_1)._X2f9Pi_1=_X2f9Pi_1) /* ?{} */); 1402 } 1403 1404 { 1405 ((void)((*_X4_dstS3Fdl_1)._X3f10Pi_1=_X3f10Pi_1) /* ?{} */); 1406 } 1407 1408 { 1409 ((void)((*_X4_dstS3Fdl_1)._X3f11Pi_1=_X3f11Pi_1) /* ?{} */); 1410 } 1411 1412 { 1413 ((void)((*_X4_dstS3Fdl_1)._X3f12Pi_1=_X3f12Pi_1) /* ?{} */); 1414 } 1415 1416 { 1417 ((void)((*_X4_dstS3Fdl_1)._X3f13Pi_1=_X3f13Pi_1) /* ?{} */); 1418 } 1419 1420 { 1421 ((void)((*_X4_dstS3Fdl_1)._X3f14Pi_1=_X3f14Pi_1) /* ?{} */); 1422 } 1423 1424 { 1425 ((void)((*_X4_dstS3Fdl_1)._X4shi3s_1=_X4shi3s_1) /* ?{} */); 1426 } 1427 1428 { 1429 ((void)((*_X4_dstS3Fdl_1)._X4shi4s_1=_X4shi4s_1) /* ?{} */); 1152 1430 } 1153 1431 … … 1405 1683 1406 1684 } 1407 __attribute__ (( noreturn )) void _X4fredFv___1(void){ 1685 void _X4fredFv___1(void){ 1686 __attribute__ ((unused)) signed int _X1ii_2; 1687 { 1688 __attribute__ ((unused)) signed int _X3reti_3; 1689 switch ( 3 ) { 1690 case 2: 1691 { 1692 { 1693 ((void)4); 1694 } 1695 1696 /* null statement */ ; 1697 /* null statement */ ; 1698 } 1699 case 1: 1700 { 1701 { 1702 ((void)3); 1703 } 1704 1705 } 1706 } 1707 1708 } 1709 1710 L: __attribute__ ((unused)) goto L; 1711 L2: __attribute__ (( unused )) L1: __attribute__ (( unused )) goto L2; 1712 return ; 1713 return ; 1714 return ; 1715 { 1716 ((void)(_X1ii_2+=((signed int )1))); 1717 } 1718 1719 } 1720 void _X4maryFv___1(void){ 1721 struct __attribute__ ((aligned(64))) S { 1722 signed int _X1ii_2; 1723 }; 1724 inline void _X12_constructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){ 1725 { 1726 ((void)((*_X4_dstS1S_2)._X1ii_2) /* ?{} */); 1727 } 1728 1729 } 1730 inline void _X12_constructorFv_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){ 1731 { 1732 ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2) /* ?{} */); 1733 } 1734 1735 } 1736 inline void _X11_destructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){ 1737 { 1738 ((void)((*_X4_dstS1S_2)._X1ii_2) /* ^?{} */); 1739 } 1740 1741 } 1742 inline struct S _X16_operator_assignFS1S_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){ 1743 __attribute__ ((unused)) struct S _X4_retS1S_2; 1744 { 1745 ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2)); 1746 } 1747 1748 { 1749 ((void)_X12_constructorFv_S1SS1S_autogen___2((&_X4_retS1S_2), (*_X4_dstS1S_2))); 1750 } 1751 1752 return _X4_retS1S_2; 1753 } 1754 inline void _X12_constructorFv_S1Si_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, signed int _X1ii_2){ 1755 { 1756 ((void)((*_X4_dstS1S_2)._X1ii_2=_X1ii_2) /* ?{} */); 1757 } 1758 1759 } 1408 1760 __attribute__ ((unused)) signed int _X1ii_2; 1409 1761 switch ( 3 ) { … … 1414 1766 } 1415 1767 1768 /* null statement */ ; 1769 /* null statement */ ; 1416 1770 } 1417 1771 case 1: … … 1424 1778 } 1425 1779 1426 { 1427 ((void)abort()); 1428 } 1429 1430 } 1431 __attribute__ ((noreturn)) void _X4maryFv___1(void){ 1432 struct __attribute__ ((aligned(16))) S { 1433 signed int _X1ii_2; 1434 }; 1435 inline void _X12_constructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){ 1436 { 1437 ((void)((*_X4_dstS1S_2)._X1ii_2) /* ?{} */); 1438 } 1439 1440 } 1441 inline void _X12_constructorFv_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){ 1442 { 1443 ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2) /* ?{} */); 1444 } 1445 1446 } 1447 inline void _X11_destructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){ 1448 { 1449 ((void)((*_X4_dstS1S_2)._X1ii_2) /* ^?{} */); 1450 } 1451 1452 } 1453 inline struct S _X16_operator_assignFS1S_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){ 1454 __attribute__ ((unused)) struct S _X4_retS1S_2; 1455 { 1456 ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2)); 1457 } 1458 1459 { 1460 ((void)_X12_constructorFv_S1SS1S_autogen___2((&_X4_retS1S_2), (*_X4_dstS1S_2))); 1461 } 1462 1463 return _X4_retS1S_2; 1464 } 1465 inline void _X12_constructorFv_S1Si_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, signed int _X1ii_2){ 1466 { 1467 ((void)((*_X4_dstS1S_2)._X1ii_2=_X1ii_2) /* ?{} */); 1468 } 1469 1470 } 1471 __attribute__ ((unused)) signed int _X1ii_2; 1472 switch ( 3 ) { 1473 case 2: 1474 { 1475 { 1476 ((void)4); 1477 } 1478 1479 } 1480 case 1: 1481 { 1482 { 1483 ((void)3); 1484 } 1485 1486 } 1487 } 1488 1489 { 1490 ((void)abort()); 1491 } 1492 1493 } 1780 L: __attribute__ ((unused)) goto L; 1781 L2: __attribute__ ((unused)) L1: __attribute__ ((unused)) goto L2; 1782 return ; 1783 return ; 1784 return ; 1785 } 1786 __attribute__ (( noreturn )) void _X4jackFv___1(void){ 1787 { 1788 ((void)exit((-((signed int )1)))); 1789 } 1790 1791 } -
tests/attributes.cfa
ra8e2215 rcd28605 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // attributes.cfa -- 6 // 7 // attributes.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Mon Feb 6 16:07:02 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 20 15:32:21 202413 // Update Count : 5312 // Last Modified On : Thu Feb 6 12:06:22 2025 13 // Update Count : 117 14 14 // 15 15 … … 37 37 38 38 // field_declaring_list 39 typedef short int shint; 39 40 struct Fdl { 40 41 int f1 __attribute__(( unused )); … … 50 51 int ( ( __attribute__(( unused )) * (f13) __attribute__(( unused )) ) __attribute__(( unused )) ); 51 52 int ( ( ( __attribute__(( unused )) * (f14) ) __attribute__(( unused )) ) __attribute__(( unused )) ); 53 // shint __attribute__(( used )) shi1; 54 // shint __attribute__(( used )) shi2 __attribute__(( used )); 55 __attribute__(( used )) shint shi3; 56 __attribute__(( used )) shint shi4 __attribute__(( used )); 57 // __attribute__(( used )) shint __attribute__(( used )) shi5 __attribute__(( used )); 52 58 }; 53 59 … … 63 69 const __attribute__(( used )) int __attribute__(( used )) (* __attribute__(( used )) vd7)() __attribute__(( used )), __attribute__(( unused )) ((* __attribute__(( used )) vd8)()) __attribute__(( used )); 64 70 const __attribute__(( used )) int __attribute__(( used )) ( __attribute__(( used )) * vd9)() __attribute__(( used )), __attribute__(( unused )) (( __attribute__(( used )) * vd10)()) __attribute__(( used )); 71 65 72 66 73 // function_declarator … … 91 98 __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) ((t6))() __attribute__(( unused )); 92 99 } 93 94 100 95 101 // identifier_parameter_declarator … … 164 170 }; 165 171 166 [[ noreturn ]] void fred() { 172 173 // statments 174 void fred() { 167 175 int [[unused]] i; 168 176 // C23 attributes are parsed but not pushed through the compiler. 169 177 // int [[gnu::xxx]] j; 170 178 switch ( 3 ) { 179 __attribute__((unused)) int ret; 171 180 case 2: 172 181 4; 173 // __attribute__(( fallthrough )) 174 // [[fallthrough]] 182 __attribute__(( fallthrough )); 183 [[fallthrough]]; 175 184 case 1: 176 185 3; 177 186 } 178 abort(); 179 } 180 181 @[ noreturn ] void mary() { 182 @[aligned(16)] struct S { int i; }; 187 L : __attribute__(( unused )) goto L; 188 L1 : [[ unused ]] L2 : [[ unused ]] goto L2; 189 __attribute__(( unused )) return; 190 [[ noreturn ]] return; 191 __attribute__(( noreturn )) return; 192 [[ GNU::fred ]] i += 1; 193 } 194 195 void mary() { 196 @[aligned(64)] struct S { int i; }; 183 197 int @[unused] i; 184 198 switch ( 3 ) { 185 199 case 2: 186 200 4; 187 // __attribute__(( fallthrough )) 188 // [[fallthrough]] 201 __attribute__(( fallthrough )); 202 @[fallthrough]; 189 203 case 1: 190 204 3; 191 205 } 192 abort(); 206 L : __attribute__(( unused )) goto L; 207 L1 : @[ unused ] L2 : @[ unused ] goto L2; 208 __attribute__(( unused )) return; 209 @[ noreturn ] return; 210 __attribute__(( noreturn )) return; 211 } 212 213 [[ noreturn ]] void jack() { 214 exit( -1 ); 193 215 } 194 216
Note:
See TracChangeset
for help on using the changeset viewer.