Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r284da8c r4c3ee8d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  6 08:02:38 2018
    13 // Update Count     : 3716
     12// Last Modified On : Mon Jul  2 20:23:14 2018
     13// Update Count     : 3607
    1414//
    1515
     
    116116
    117117void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) {
    118         // distribute qualifiers across all non-variable declarations in a distribution statemement
     118        // distribute qualifiers across all declarations in a distribution statemement
    119119        for ( DeclarationNode * iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    120                 // SKULLDUGGERY: Distributions are parsed inside out, so qualifiers are added to declarations inside out. Since
    121                 // addQualifiers appends to the back of the list, the forall clauses are in the wrong order (right to left). To
    122                 // get the qualifiers in the correct order and still use addQualifiers (otherwise, 90% of addQualifiers has to
    123                 // be copied to add to front), the appropriate forall pointers are interchanged before calling addQualifiers.
    124                 DeclarationNode * clone = qualifiers->clone();
    125                 if ( qualifiers->type ) {                                               // forall clause ? (handles SC)
    126                         if ( iter->type->kind == TypeData::Aggregate ) { // struct/union ?
    127                                 swap( clone->type->forall, iter->type->aggregate.params );
    128                                 iter->addQualifiers( clone );
    129                         } else if ( iter->type->kind == TypeData::AggregateInst && iter->type->aggInst.aggregate->aggregate.body ) { // struct/union ?
    130                                 // Create temporary node to hold aggregate, call addQualifiers as above, then put nodes back together.
    131                                 DeclarationNode newnode;
    132                                 swap( newnode.type, iter->type->aggInst.aggregate );
    133                                 swap( clone->type->forall, newnode.type->aggregate.params );
    134                                 newnode.addQualifiers( clone );
    135                                 swap( newnode.type, iter->type->aggInst.aggregate );
    136                         } else if ( iter->type->kind == TypeData::Function ) { // routines ?
    137                                 swap( clone->type->forall, iter->type->forall );
    138                                 iter->addQualifiers( clone );
    139                         } // if
    140                 } else {                                                                                // just SC qualifiers
    141                         iter->addQualifiers( clone );
     120                if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
     121                        iter->addQualifiers( qualifiers->clone() );
    142122                } // if
    143123        } // for
    144         delete qualifiers;
    145 } // distQual
     124} // distExt
    146125
    147126// There is an ambiguity for inline generic-routine return-types and generic routines.
     
    387366%type<decl> type_parameter type_parameter_list type_initializer_opt
    388367
    389 %type<en> type_parameters_opt type_list
     368%type<en> type_list
    390369
    391370%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
     
    427406// Order of these lines matters (low-to-high precedence).
    428407%precedence TYPEGENname
    429 %precedence '}'
    430408%precedence '('
    431409
     
    17751753                { $$ = $3->addQualifiers( $1 ); }
    17761754        | sue_type_specifier type_qualifier
    1777                 {
    1778                         if ( $2->type != nullptr && $2->type->forall ) forall = true; // remember generic type
    1779                         $$ = $1->addQualifiers( $2 );
    1780                 }
     1755                { $$ = $1->addQualifiers( $2 ); }
    17811756        ;
    17821757
     
    18561831
    18571832aggregate_type:                                                                                 // struct, union
    1858         aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' type_parameters_opt
    1859                 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $6, $4, true )->addQualifiers( $2 ); }
     1833        aggregate_key attribute_list_opt '{' field_declaration_list_opt '}'
     1834                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }
    18601835        | aggregate_key attribute_list_opt no_attr_identifier fred
    18611836                {
     
    18631838                        forall = false;                                                         // reset
    18641839                }
    1865           '{' field_declaration_list_opt '}' type_parameters_opt
    1866                 { $$ = DeclarationNode::newAggregate( $1, $3, $9, $7, true )->addQualifiers( $2 ); }
     1840          '{' field_declaration_list_opt '}'
     1841                { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $7, true )->addQualifiers( $2 ); }
    18671842        | aggregate_key attribute_list_opt type_name fred
    18681843                {
     
    18701845                        forall = false;                                                         // reset
    18711846                }
    1872           '{' field_declaration_list_opt '}' type_parameters_opt
    1873                 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $9, $7, true )->addQualifiers( $2 ); }
     1847          '{' field_declaration_list_opt '}'
     1848                { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $7, true )->addQualifiers( $2 ); }
     1849        | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA
     1850                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }
    18741851        | aggregate_type_nobody
    1875         ;
    1876 
    1877 type_parameters_opt:
    1878         // empty
    1879                 { $$ = nullptr; }                                                               %prec '}'
    1880         | '(' type_list ')'
    1881                 { $$ = $2; }
    18821852        ;
    18831853
     
    24182388                        distQual( $5, $1 );
    24192389                        xxx = false;
     2390                        delete $1;
    24202391                        $$ = $5;
    24212392                }
     
    24292400                        distQual( $5, $1 );
    24302401                        xxx = false;
     2402                        delete $1;
    24312403                        $$ = $5;
    24322404                }
     
    24382410          '{' up external_definition_list_opt down '}'          // CFA, namespace
    24392411                {
    2440                         distQual( $6, $1->addQualifiers( $2 ) );
     2412                        distQual( $6, $2 );
     2413                        distQual( $6, $1 );
    24412414                        xxx = false;
     2415                        delete $1;
     2416                        delete $2;
    24422417                        $$ = $6;
    24432418                }
Note: See TracChangeset for help on using the changeset viewer.