Changeset 3ed994e
- Timestamp:
- May 29, 2018, 2:02:47 PM (6 years ago)
- 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 96812c0
- Parents:
- d807ca28
- git-author:
- Rob Schluntz <rschlunt@…> (05/29/18 12:29:01)
- git-committer:
- Rob Schluntz <rschlunt@…> (05/29/18 14:02:47)
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rd807ca28 r3ed994e 171 171 // *** Declarations 172 172 void CodeGenerator::postvisit( FunctionDecl * functionDecl ) { 173 // deleted decls should never be used, so don't print them 174 if ( functionDecl->isDeleted && genC ) return; 173 175 extension( functionDecl ); 174 176 genAttributes( functionDecl->get_attributes() ); … … 184 186 functionDecl->get_statements()->accept( *visitor ); 185 187 } // if 188 if ( functionDecl->isDeleted ) { 189 output << " = void"; 190 } 186 191 } 187 192 188 193 void CodeGenerator::postvisit( ObjectDecl * objectDecl ) { 194 // deleted decls should never be used, so don't print them 195 if ( objectDecl->isDeleted && genC ) return; 189 196 if (objectDecl->get_name().empty() && genC ) { 190 197 // only generate an anonymous name when generating C code, otherwise it clutters the output too much … … 205 212 objectDecl->get_init()->accept( *visitor ); 206 213 } // if 214 if ( objectDecl->isDeleted ) { 215 output << " = void"; 216 } 207 217 208 218 if ( objectDecl->get_bitfieldWidth() ) { -
src/Common/PassVisitor.h
rd807ca28 r3ed994e 313 313 void indexerAddUnionFwd ( UnionDecl * node ) { indexer_impl_addUnionFwd ( pass, 0, node ); } 314 314 void indexerAddTrait ( TraitDecl * node ) { indexer_impl_addTrait ( pass, 0, node ); } 315 void indexerAddWith ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith 315 void indexerAddWith ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); } 316 316 317 317 -
src/Parser/DeclarationNode.cc
rd807ca28 r3ed994e 1067 1067 SemanticError( this, "invalid function specifier for " ); 1068 1068 } // if 1069 return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); 1069 bool isDelete = initializer && initializer->get_isDelete(); 1070 Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); 1071 if ( isDelete ) { 1072 DeclarationWithType * dwt = strict_dynamic_cast<DeclarationWithType *>( decl ); 1073 dwt->isDeleted = true; 1074 } 1075 return decl; 1070 1076 } // if 1071 1077 -
src/Parser/InitializerNode.cc
rd807ca28 r3ed994e 27 27 28 28 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des ) 29 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {29 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) { 30 30 if ( aggrp ) 31 31 kids = dynamic_cast< InitializerNode * >( get_next() ); … … 36 36 37 37 InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des ) 38 : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {38 : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) { 39 39 if ( init ) 40 40 set_last( init ); … … 46 46 set_next( nullptr ); 47 47 } // InitializerNode::InitializerNode 48 49 InitializerNode::InitializerNode( bool isDelete ) : expr( nullptr ), aggregate( false ), designator( nullptr ), kids( nullptr ), maybeConstructed( false ), isDelete( isDelete ) {} 48 50 49 51 InitializerNode::~InitializerNode() { … … 84 86 85 87 Initializer * InitializerNode::build() const { 88 assertf( ! isDelete, "Should not build delete stmt InitializerNode" ); 86 89 if ( aggregate ) { 87 90 // steal designators from children -
src/Parser/ParseNode.h
rd807ca28 r3ed994e 87 87 InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode * des = nullptr ); 88 88 InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr ); 89 InitializerNode( bool isDelete ); 89 90 ~InitializerNode(); 90 91 virtual InitializerNode * clone() const { assert( false ); return nullptr; } … … 97 98 InitializerNode * set_maybeConstructed( bool value ) { maybeConstructed = value; return this; } 98 99 bool get_maybeConstructed() const { return maybeConstructed; } 100 101 bool get_isDelete() const { return isDelete; } 99 102 100 103 InitializerNode * next_init() const { return kids; } … … 110 113 InitializerNode * kids; 111 114 bool maybeConstructed; 115 bool isDelete; 112 116 }; // InitializerNode 113 117 -
src/Parser/parser.yy
rd807ca28 r3ed994e 2113 2113 { $$ = $2; } 2114 2114 | '=' VOID 2115 { $$ = n ullptr; }2115 { $$ = new InitializerNode( true ); } 2116 2116 | ATassign initializer 2117 2117 { $$ = $2->set_maybeConstructed( false ); } -
src/SymTab/Indexer.cc
rd807ca28 r3ed994e 471 471 void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) { 472 472 // default handling of conflicts is to raise an error 473 addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, baseExpr );473 addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, baseExpr, decl->isDeleted ? decl : nullptr ); 474 474 } 475 475 -
src/SynTree/Declaration.cc
rd807ca28 r3ed994e 104 104 } 105 105 106 106 107 // Local Variables: // 107 108 // tab-width: 4 // -
src/SynTree/Declaration.h
rd807ca28 r3ed994e 84 84 Expression *asmName; 85 85 std::list< Attribute * > attributes; 86 bool isDeleted = false; 86 87 87 88 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
Note: See TracChangeset
for help on using the changeset viewer.