Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r45161b4d r984dce6  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 13 16:53:17 2016
    13 // Update Count     : 161
     12// Last Modified On : Mon Mar 21 21:04:23 2016
     13// Update Count     : 142
    1414//
    1515
     
    188188        newnode->type->aggregate->name = assign_strptr( name );
    189189        if ( newnode->type->aggregate->name == "" ) {           // anonymous aggregate ?
    190                 newnode->type->aggregate->name = anonymous.newName();
     190                newnode->type->aggregate->name = DeclarationNode::anonymous.newName();
     191        } else if ( ! typedefTable.exists( newnode->type->aggregate->name ) ) {
     192                // SKULLDUGGERY: Generate a typedef for the aggregate name so the aggregate does not have to be qualified by
     193                // "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed
     194                // if the name is explicitly used.
     195                typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD );
     196                DeclarationNode *typedf = new DeclarationNode;
     197                typedf->name = newnode->type->aggregate->name;
     198                newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
    191199        } // if
    192200        newnode->type->aggregate->actuals = actuals;
     
    202210        if ( newnode->type->enumeration->name == "" ) {         // anonymous enumeration ?
    203211                newnode->type->enumeration->name = DeclarationNode::anonymous.newName();
     212        } else if ( ! typedefTable.exists( newnode->type->enumeration->name ) ) {
     213                // SKULLDUGGERY: Generate a typedef for the enumeration name so the enumeration does not have to be qualified by
     214                // "enum". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if
     215                // the name is explicitly used.
     216                typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD );
     217                DeclarationNode *typedf = new DeclarationNode;
     218                typedf->name = newnode->type->enumeration->name;
     219                newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
    204220        } // if
    205221        newnode->type->enumeration->constants = constants;
Note: See TracChangeset for help on using the changeset viewer.