Changes in / [c0b23644:5c4d27f]


Ignore:
Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rc0b23644 r5c4d27f  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 20 09:21:52 2017
    13 // Update Count     : 1031
     12// Last Modified On : Sat Sep 23 18:16:48 2017
     13// Update Count     : 1024
    1414//
    1515
     
    509509
    510510DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) {
    511         if ( ! q ) { delete q; return this; }                           // empty qualifier
     511        if ( ! q ) { delete q; return this; }
    512512
    513513        checkSpecifiers( q );
    514514        copySpecifiers( q );
    515515
    516         if ( ! q->type ) { delete q; return this; }
     516        if ( ! q->type ) {
     517                delete q;
     518                return this;
     519        } // if
    517520
    518521        if ( ! type ) {
    519                 type = q->type;                                                                 // reuse structure
     522                type = q->type;                                                                 // reuse this structure
    520523                q->type = nullptr;
    521524                delete q;
     
    523526        } // if
    524527
    525         if ( q->type->forall ) {                                                        // forall qualifier ?
    526                 if ( type->forall ) {                                                   // polymorphic routine ?
    527                         type->forall->appendList( q->type->forall ); // augment forall qualifier
     528        if ( q->type->forall ) {
     529                if ( type->forall ) {
     530                        type->forall->appendList( q->type->forall );
    528531                } else {
    529                         if ( type->kind == TypeData::Aggregate ) {      // struct/union ?
    530                                 if ( type->aggregate.params ) {                 // polymorphic ?
    531                                         type->aggregate.params->appendList( q->type->forall ); // augment forall qualifier
    532                                 } else {                                                                // not polymorphic
    533                                         type->aggregate.params = q->type->forall; // make polymorphic type
    534                                         // change implicit typedef from TYPEDEFname to TYPEGENname
    535                                         typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
    536                                 } // if
    537                         } else {                                                                        // not polymorphic
    538                                 type->forall = q->type->forall;                 // make polymorphic routine
     532                        if ( type->kind == TypeData::Aggregate ) {
     533                                type->aggregate.params = q->type->forall;
     534                                // change implicit typedef from TYPEDEFname to TYPEGENname
     535                                typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
     536                        } else {
     537                                type->forall = q->type->forall;
    539538                        } // if
    540539                } // if
    541                 q->type->forall = nullptr;                                              // forall qualifier moved
     540                q->type->forall = nullptr;
    542541        } // if
    543542
  • src/Parser/parser.yy

    rc0b23644 r5c4d27f  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 20 09:45:36 2017
    13 // Update Count     : 2945
     12// Last Modified On : Fri Nov 17 11:38:57 2017
     13// Update Count     : 2914
    1414//
    1515
     
    114114        } // for
    115115} // distExt
    116 
    117 // There is an ambiguity for inline generic-routine return-types and generic routines.
    118 //   forall( otype T ) struct S { int i; } bar( T ) {}
    119 // Does the forall bind to the struct or the routine, and how would it be possible to explicitly specify the binding.
    120 //   forall( otype T ) struct S { int T; } forall( otype W ) bar( W ) {}
    121 
    122 void rebindForall( DeclarationNode * declSpec, DeclarationNode * funcDecl ) {
    123         if ( declSpec->type->kind == TypeData::Aggregate ) { // return is aggregate definition
    124                 funcDecl->type->forall = declSpec->type->aggregate.params; // move forall from aggregate to function type
    125                 declSpec->type->aggregate.params = nullptr;
    126         } // if
    127 } // rebindForall
    128116
    129117bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    24132401        | declaration_specifier function_declarator with_clause_opt compound_statement
    24142402                {
    2415                         rebindForall( $1, $2 );
    24162403                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    24172404                        typedefTable.leaveScope();
     
    24402427        | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24412428                {
    2442                         rebindForall( $1, $2 );
    24432429                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    24442430                        typedefTable.leaveScope();
Note: See TracChangeset for help on using the changeset viewer.