Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r3f024c9 rb2da0574  
    2626#include "Common/SemanticError.h"  // for SemanticError
    2727#include "Common/utility.h"        // for cloneAll
    28 #include "GenPoly/GenPoly.h"
    2928#include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
    3029#include "Mangler.h"               // for Mangler
     
    378377        }
    379378
    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 
    399379        bool addedIdConflicts( Indexer::IdData & existing, DeclarationWithType *added, BaseSyntaxNode * deleteStmt, Indexer::ConflictFunction handleConflicts ) {
    400380                // 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 ) ) );
    403383
    404384                if ( LinkageSpec::isOverridable( existing.id->get_linkage() ) ) {
     
    414394                        }
    415395
    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() ) {
    418402                                        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 ) {
    420412                                        return handleConflicts( existing, "duplicate object definition for " );
    421413                                } // if
Note: See TracChangeset for help on using the changeset viewer.