Changes in / [d1b9d78:ed9ecda]


Ignore:
Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    rd1b9d78 red9ecda  
    526526
    527527                return tables->base.hasIncompatibleCDecl( id, mangleName, scope );
    528         }
    529 
    530         bool Indexer::hasCompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const {
    531                 if ( ! tables ) return false;
    532                 if ( tables->scope < scope ) return false;
    533 
    534                 IdTable::const_iterator decls = tables->idTable.find( id );
    535                 if ( decls != tables->idTable.end() ) {
    536                         const MangleTable &mangleTable = decls->second;
    537                         for ( MangleTable::const_iterator decl = mangleTable.begin(); decl != mangleTable.end(); ++decl ) {
    538                                 // check for C decls with the same name, skipping
    539                                 // those with an incompatible type (by mangleName)
    540                                 if ( decl->second->get_linkage() == LinkageSpec::C && decl->first == mangleName ) return true;
    541                         }
    542                 }
    543 
    544                 return tables->base.hasCompatibleCDecl( id, mangleName, scope );
    545528        }
    546529
     
    633616                } // if
    634617
    635                 // this ensures that no two declarations with the same unmangled name at the same scope both have C linkage
    636                 if ( decl->get_linkage() == LinkageSpec::C ) {
    637                         // NOTE this is broken in Richard's original code in such a way that it never triggers (it
    638                         // doesn't check decls that have the same manglename, and all C-linkage decls are defined to
    639                         // have their name as their manglename, hence the error can never trigger).
    640                         // The code here is closer to correct, but name mangling would have to be completely
    641                         // isomorphic to C type-compatibility, which it may not be.
    642                         if ( hasIncompatibleCDecl( name, mangleName, scope ) ) {
    643                                 throw SemanticError( "conflicting overload of C function ", decl );
    644                         }
    645                 } else {
    646                         // Check that a Cforall declaration doesn't overload any C declaration
    647                         if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    648                                 throw SemanticError( "Cforall declaration hides C function ", decl );
    649                         }
    650                 }
    651 
    652                 // Skip repeat declarations of the same identifier
    653618                DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );
    654                 if ( existing && addedIdConflicts( existing, decl ) ) return;
    655 
    656                 // add to indexer
    657                 tables->idTable[ name ][ mangleName ] = decl;
    658                 ++tables->size;
     619                if ( ! existing || ! addedIdConflicts( existing, decl ) ) {
     620                        // this ensures that no two declarations with the same unmangled name at the same scope both have C linkage
     621                        if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName, scope ) ) {
     622                                throw SemanticError( "invalid overload of C function ", decl );
     623                        } // NOTE this is broken in Richard's original code in such a way that it never triggers (it
     624                          // doesn't check decls that have the same manglename, and all C-linkage decls are defined to
     625                          // have their name as their manglename, hence the error can never trigger).
     626                          // The code here is closer to correct, but name mangling would have to be completely
     627                          // isomorphic to C type-compatibility, which it may not be.
     628
     629                        tables->idTable[ name ][ mangleName ] = decl;
     630                        ++tables->size;
     631                }
    659632        }
    660633
  • src/SymTab/Indexer.h

    rd1b9d78 red9ecda  
    100100                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
    101101                bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    102                 /// returns true if there exists a declaration with C linkage and the given name with the same mangled name
    103                 bool hasCompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    104102                // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
    105103                NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
  • src/SymTab/Mangler.cc

    rd1b9d78 red9ecda  
    282282                        mangleName << "V";
    283283                } // if
    284                 // Removed due to restrict not affecting function compatibility in GCC
    285 //              if ( type->get_isRestrict() ) {
    286 //                      mangleName << "R";
    287 //              } // if
     284                if ( type->get_isRestrict() ) {
     285                        mangleName << "R";
     286                } // if
    288287                if ( type->get_isLvalue() ) {
    289288                        mangleName << "L";
  • src/libcfa/math

    rd1b9d78 red9ecda  
    184184
    185185float atan2( float, float );
    186 // extern "C" { double atan2( double, double ); }
     186double atan2( double, double );
    187187long double atan2( long double, long double );
    188188
  • src/libcfa/math.c

    rd1b9d78 red9ecda  
    2323long double fabs( long double x ) { return fabsl( x ); }
    2424float cabs( float _Complex x ) { return cabsf( x ); }
     25double cabs( double _Complex x ) { return cabs( x ); }
    2526long double cabs( long double _Complex x ) { return cabsl( x ); }
    2627
     
    158159
    159160float atan2( float x, float y ) { return atan2f( x, y ); }
     161double atan2( double x, double y ) { return atan2( x, y ); }
    160162long double atan2( long double x, long double y ) { return atan2l( x, y ); }
    161163
Note: See TracChangeset for help on using the changeset viewer.