Changeset 3f024c9
- Timestamp:
- May 4, 2018, 11:01:48 AM (7 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:
- 7d0a3ba
- Parents:
- f3152ab
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
rf3152ab r3f024c9 26 26 #include "Common/SemanticError.h" // for SemanticError 27 27 #include "Common/utility.h" // for cloneAll 28 #include "GenPoly/GenPoly.h" 28 29 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... 29 30 #include "Mangler.h" // for Mangler … … 377 378 } 378 379 380 bool isFunction( DeclarationWithType * decl ) { 381 return GenPoly::getFunctionType( decl->get_type() ); 382 } 383 384 bool isObject( DeclarationWithType * decl ) { 385 return ! isFunction( decl ); 386 } 387 388 bool isDefinition( DeclarationWithType * decl ) { 389 if ( FunctionDecl * func = dynamic_cast< FunctionDecl * >( decl ) ) { 390 // a function is a definition if it has a body 391 return func->statements; 392 } else { 393 // an object is a definition if it is not marked extern. 394 // both objects must be marked extern 395 return ! decl->get_storageClasses().is_extern; 396 } 397 } 398 379 399 bool addedIdConflicts( Indexer::IdData & existing, DeclarationWithType *added, BaseSyntaxNode * deleteStmt, Indexer::ConflictFunction handleConflicts ) { 380 400 // if we're giving the same name mangling to things of different types then there is something wrong 381 assert( ( dynamic_cast<ObjectDecl*>( added ) && dynamic_cast<ObjectDecl*>( existing.id ) )382 || ( dynamic_cast<FunctionDecl*>( added ) && dynamic_cast<FunctionDecl*>( existing.id ) ) );401 assert( (isObject( added ) && isObject( existing.id ) ) 402 || ( isFunction( added ) && isFunction( existing.id ) ) ); 383 403 384 404 if ( LinkageSpec::isOverridable( existing.id->get_linkage() ) ) { … … 394 414 } 395 415 396 // typesCompatible doesn't really do the right thing here. When checking compatibility of function types, 397 // we should ignore outermost pointer qualifiers, except _Atomic? 398 FunctionDecl * newentry = dynamic_cast< FunctionDecl * >( added ); 399 FunctionDecl * oldentry = dynamic_cast< FunctionDecl * >( existing.id ); 400 if ( newentry && oldentry ) { 401 if ( newentry->get_statements() && oldentry->get_statements() ) { 416 if ( isDefinition( added ) && isDefinition( existing.id ) ) { 417 if ( isFunction( added ) ) { 402 418 return handleConflicts( existing, "duplicate function definition for " ); 403 } // if 404 } else { 405 // two objects with the same mangled name defined in the same scope. 406 // both objects must be marked extern or both must be intrinsic for this to be okay 407 // xxx - perhaps it's actually if either is intrinsic then this is okay? 408 // might also need to be same storage class? 409 ObjectDecl * newobj = dynamic_cast< ObjectDecl * >( added ); 410 ObjectDecl * oldobj = dynamic_cast< ObjectDecl * >( existing.id ); 411 if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) { 419 } else { 412 420 return handleConflicts( existing, "duplicate object definition for " ); 413 421 } // if -
src/SymTab/Mangler.cc
rf3152ab r3f024c9 179 179 void Mangler::postvisit( PointerType * pointerType ) { 180 180 printQualifiers( pointerType ); 181 mangleName << "P"; 181 // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers 182 if ( ! dynamic_cast<FunctionType *>( pointerType->base ) ) mangleName << "P"; 182 183 maybeAccept( pointerType->base, *visitor ); 183 184 }
Note: See TracChangeset
for help on using the changeset viewer.