Changes in src/SymTab/Indexer.cc [3f024c9:b2da0574]
- File:
-
- 1 edited
-
src/SymTab/Indexer.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
r3f024c9 rb2da0574 26 26 #include "Common/SemanticError.h" // for SemanticError 27 27 #include "Common/utility.h" // for cloneAll 28 #include "GenPoly/GenPoly.h"29 28 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... 30 29 #include "Mangler.h" // for Mangler … … 378 377 } 379 378 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 body391 return func->statements;392 } else {393 // an object is a definition if it is not marked extern.394 // both objects must be marked extern395 return ! decl->get_storageClasses().is_extern;396 }397 }398 399 379 bool addedIdConflicts( Indexer::IdData & existing, DeclarationWithType *added, BaseSyntaxNode * deleteStmt, Indexer::ConflictFunction handleConflicts ) { 400 380 // if we're giving the same name mangling to things of different types then there is something wrong 401 assert( ( isObject( added ) && isObject( existing.id ) )402 || ( isFunction( added ) && isFunction( existing.id ) ) );381 assert( (dynamic_cast<ObjectDecl*>( added ) && dynamic_cast<ObjectDecl*>( existing.id ) ) 382 || (dynamic_cast<FunctionDecl*>( added ) && dynamic_cast<FunctionDecl*>( existing.id ) ) ); 403 383 404 384 if ( LinkageSpec::isOverridable( existing.id->get_linkage() ) ) { … … 414 394 } 415 395 416 if ( isDefinition( added ) && isDefinition( existing.id ) ) { 417 if ( isFunction( added ) ) { 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() ) { 418 402 return handleConflicts( existing, "duplicate function definition for " ); 419 } else { 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 ) { 420 412 return handleConflicts( existing, "duplicate object definition for " ); 421 413 } // if
Note:
See TracChangeset
for help on using the changeset viewer.