Ignore:
Timestamp:
Jul 11, 2018, 11:53:09 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
777ed2b
Parents:
132d276
Message:

fix distribution to put type names at correct scopes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r132d276 rfc20514  
    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 : Wed Jul 11 11:20:51 2018
     13// Update Count     : 3738
    1414//
    1515
     
    166166} // build_postfix_name
    167167
    168 bool forall = false, xxx = false, yyy = false;                  // aggregate have one or more forall qualifiers ?
     168bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    169169
    170170// https://www.gnu.org/software/bison/manual/bison.html#Location-Type
     
    422422//   Foo ( *fp )( int );
    423423//   `---'                                              matches start of TYPEGENname '('
    424 // Must be:
     424// must be:
    425425//   Foo( int ) ( *fp )( int );
     426// The same problem occurs here:
     427//   forall( otype T ) struct Foo { T v; } ( *fp )( int );
     428// must be:
     429//   forall( otype T ) struct Foo { T v; } ( int ) ( *fp )( int );
    426430
    427431// Order of these lines matters (low-to-high precedence).
     
    18561860
    18571861aggregate_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 ); }
     1862        aggregate_key attribute_list_opt
     1863                { forall = false; }                                                             // reset
     1864          '{' field_declaration_list_opt '}' type_parameters_opt
     1865                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $7, $5, true )->addQualifiers( $2 ); }
    18601866        | aggregate_key attribute_list_opt no_attr_identifier fred
    18611867                {
    1862                         typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef
     1868                        typedefTable.makeTypedef( *$3, forall | typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    18631869                        forall = false;                                                         // reset
    18641870                }
     
    18671873        | aggregate_key attribute_list_opt type_name fred
    18681874                {
    1869                         typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef
     1875                        typedefTable.makeTypedef( *$3->type->symbolic.name, forall | typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    18701876                        forall = false;                                                         // reset
    18711877                }
     
    18851891        aggregate_key attribute_list_opt no_attr_identifier fred
    18861892                {
    1887                         typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname );
     1893                        typedefTable.makeTypedef( *$3, forall | typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
    18881894                        forall = false;                                                         // reset
    18891895                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     
    18911897        | aggregate_key attribute_list_opt type_name fred
    18921898                {
     1899                        forall = false;                                                         // reset
    18931900                        // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is
    18941901                        // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and
     
    23662373        push external_definition pop
    23672374                { $$ = $2; }
    2368         | external_definition_list
    2369                 { forall = xxx; }
    2370           push external_definition pop
    2371                 { $$ = $1 ? $1->appendList( $4 ) : $4; }
     2375        | external_definition_list push external_definition pop
     2376                { $$ = $1 ? $1->appendList( $3 ) : $3; }
    23722377        ;
    23732378
     
    23792384
    23802385up:
    2381                 { typedefTable.up(); }
     2386                { typedefTable.up( forall ); forall = false; }
    23822387        ;
    23832388
     
    24122417                {
    24132418                        if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    2414                         if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2419                        if ( $1->type->forall ) forall = true;          // remember generic type
    24152420                }
    24162421          '{' up external_definition_list_opt down '}'          // CFA, namespace
    24172422                {
    24182423                        distQual( $5, $1 );
    2419                         xxx = false;
     2424                        forall = false;
    24202425                        $$ = $5;
    24212426                }
     
    24232428                {
    24242429                        if ( $1->type && $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    2425                         if ( $1->type && $1->type->forall ) xxx = forall = true; // remember generic type
     2430                        if ( $1->type && $1->type->forall ) forall = true; // remember generic type
    24262431                }
    24272432          '{' up external_definition_list_opt down '}'          // CFA, namespace
    24282433                {
    24292434                        distQual( $5, $1 );
    2430                         xxx = false;
     2435                        forall = false;
    24312436                        $$ = $5;
    24322437                }
     
    24342439                {
    24352440                        if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
    2436                         if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type
     2441                        if ( ($1->type && $1->type->forall) || $2->type->forall ) forall = true; // remember generic type
    24372442                }
    24382443          '{' up external_definition_list_opt down '}'          // CFA, namespace
    24392444                {
    24402445                        distQual( $6, $1->addQualifiers( $2 ) );
    2441                         xxx = false;
     2446                        forall = false;
    24422447                        $$ = $6;
    24432448                }
Note: See TracChangeset for help on using the changeset viewer.