Changes in src/SymTab/Indexer.cc [b2da0574:3f024c9]
- File:
-
- 1 edited
-
src/SymTab/Indexer.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
rb2da0574 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
Note:
See TracChangeset
for help on using the changeset viewer.