Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r13073be r3ed994e  
    119119
    120120        string CodeGenerator::mangleName( DeclarationWithType * decl ) {
    121                 // GCC builtins should always be printed unmangled
    122                 if ( pretty || decl->linkage.is_gcc_builtin ) return decl->name;
    123                 if ( decl->mangleName != "" ) {
     121                if ( pretty ) return decl->get_name();
     122                if ( decl->get_mangleName() != "" ) {
    124123                        // need to incorporate scope level in order to differentiate names for destructors
    125124                        return decl->get_scopedMangleName();
    126125                } else {
    127                         return decl->name;
     126                        return decl->get_name();
    128127                } // if
    129128        }
     
    172171        // *** Declarations
    173172        void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
     173                // deleted decls should never be used, so don't print them
     174                if ( functionDecl->isDeleted && genC ) return;
    174175                extension( functionDecl );
    175176                genAttributes( functionDecl->get_attributes() );
     
    185186                        functionDecl->get_statements()->accept( *visitor );
    186187                } // if
     188                if ( functionDecl->isDeleted ) {
     189                        output << " = void";
     190                }
    187191        }
    188192
    189193        void CodeGenerator::postvisit( ObjectDecl * objectDecl ) {
     194                // deleted decls should never be used, so don't print them
     195                if ( objectDecl->isDeleted && genC ) return;
    190196                if (objectDecl->get_name().empty() && genC ) {
    191197                        // only generate an anonymous name when generating C code, otherwise it clutters the output too much
     
    206212                        objectDecl->get_init()->accept( *visitor );
    207213                } // if
     214                if ( objectDecl->isDeleted ) {
     215                        output << " = void";
     216                }
    208217
    209218                if ( objectDecl->get_bitfieldWidth() ) {
     
    827836                expr->expr->accept( *visitor );
    828837        }
     838
     839        void CodeGenerator::postvisit( GenericExpr * expr ) {
     840                assertf( ! genC, "C11 _Generic expressions should not reach code generation." );
     841                output << "_Generic(";
     842                expr->control->accept( *visitor );
     843                output << ", ";
     844                unsigned int numAssocs = expr->associations.size();
     845                unsigned int i = 0;
     846                for ( GenericExpr::Association & assoc : expr->associations ) {
     847                        if (assoc.isDefault) {
     848                                output << "default: ";
     849                        } else {
     850                                output << genType( assoc.type, "", pretty, genC ) << ": ";
     851                        }
     852                        assoc.expr->accept( *visitor );
     853                        if ( i+1 != numAssocs ) {
     854                                output << ", ";
     855                        }
     856                        i++;
     857                }
     858                output << ")";
     859        }
     860
    829861
    830862        // *** Statements
Note: See TracChangeset for help on using the changeset viewer.