Changeset d55d7a6 for src/SymTab


Ignore:
Timestamp:
Feb 15, 2018, 3:58:56 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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, resolv-new, with_gc
Children:
75e3cb2
Parents:
d27e340
Message:

Massive change to errors to enable warnings

Location:
src/SymTab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    rd27e340 rd55d7a6  
    388388                        if ( newentry && oldentry ) {
    389389                                if ( newentry->get_statements() && oldentry->get_statements() ) {
    390                                         throw SemanticError( "duplicate function definition for ", added );
     390                                        throw SemanticError( added, "duplicate function definition for " );
    391391                                } // if
    392392                        } else {
     
    398398                                ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing );
    399399                                if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) {
    400                                         throw SemanticError( "duplicate object definition for ", added );
     400                                        throw SemanticError( added, "duplicate object definition for " );
    401401                                } // if
    402402                        } // if
    403403                } else {
    404                         throw SemanticError( "duplicate definition for ", added );
     404                        throw SemanticError( added, "duplicate definition for " );
    405405                } // if
    406406
     
    431431                        // isomorphic to C type-compatibility, which it may not be.
    432432                        if ( hasIncompatibleCDecl( name, mangleName, scope ) ) {
    433                                 throw SemanticError( "conflicting overload of C function ", decl );
     433                                throw SemanticError( decl, "conflicting overload of C function " );
    434434                        }
    435435                } else {
    436436                        // Check that a Cforall declaration doesn't overload any C declaration
    437437                        if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    438                                 throw SemanticError( "Cforall declaration hides C function ", decl );
     438                                throw SemanticError( decl, "Cforall declaration hides C function " );
    439439                        }
    440440                }
     
    455455                        return true;
    456456                } else {
    457                         throw SemanticError( "redeclaration of ", added );
     457                        throw SemanticError( added, "redeclaration of " );
    458458                }
    459459        }
     
    482482                        return false;
    483483                } else if ( ! added->get_members().empty() ) {
    484                         throw SemanticError( "redeclaration of ", added );
     484                        throw SemanticError( added, "redeclaration of " );
    485485                } // if
    486486                return true;
  • src/SymTab/Validate.cc

    rd27e340 rd55d7a6  
    366366                                dwts.erase( j );
    367367                                if ( i != end ) {
    368                                         throw SemanticError( "invalid type void in function type ", func );
     368                                        throw SemanticError( func, "invalid type void in function type " );
    369369                                } // if
    370370                        } else {
     
    374374                                        *i = (*i)->acceptMutator( fixer );
    375375                                        if ( fixer.pass.isVoid ) {
    376                                                 throw SemanticError( "invalid type void in function type ", func );
     376                                                throw SemanticError( func, "invalid type void in function type " );
    377377                                        } // if
    378378                                } // for
     
    411411                for ( Expression * param : inst->parameters ) {
    412412                        if ( ! dynamic_cast< TypeExpr * >( param ) ) {
    413                                 throw SemanticError( "Expression parameters for generic types are currently unsupported: ", inst );
     413                                throw SemanticError( inst, "Expression parameters for generic types are currently unsupported: " );
    414414                        }
    415415                }
     
    511511                TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name );
    512512                if ( ! traitDecl ) {
    513                         throw SemanticError( "use of undeclared trait " + traitInst->name );
     513                        throw SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
    514514                } // if
    515515                if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) {
    516                         throw SemanticError( "incorrect number of trait parameters: ", traitInst );
     516                        throw SemanticError( traitInst, "incorrect number of trait parameters: " );
    517517                } // if
    518518                traitInst->baseTrait = traitDecl;
     
    522522                        TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) );
    523523                        if ( ! expr ) {
    524                                 throw SemanticError( "Expression parameters for trait instances are currently unsupported: ", std::get<1>(p) );
     524                                throw SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );
    525525                        }
    526526                        if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) {
     
    629629                                assertion = assertion->acceptMutator( fixer );
    630630                                if ( fixer.pass.isVoid ) {
    631                                         throw SemanticError( "invalid type void in assertion of function ", node );
     631                                        throw SemanticError( node, "invalid type void in assertion of function " );
    632632                                } // if
    633633                        } // for
     
    673673                // were cast to void.
    674674                if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) {
    675                         throw SemanticError( "Non-void function returns no values: " , returnStmt );
     675                        throw SemanticError( returnStmt, "Non-void function returns no values: " );
    676676                }
    677677        }
     
    714714                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    715715                                if ( ! rtt ) {
    716                                         throw SemanticError("Cannot apply type parameters to base type of " + typeInst->name);
     716                                        throw SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );
    717717                                }
    718718                                rtt->get_parameters().clear();
     
    752752                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
    753753                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
    754                                 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
     754                                throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    755755                        }
    756756                        // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs
     
    759759                        // to fix this corner case likely outweighs the utility of allowing it.
    760760                        if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) {
    761                                 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
     761                                throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    762762                        }
    763763                } else {
     
    908908                if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
    909909                        if ( params.size() == 0 ) {
    910                                 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl );
     910                                throw SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
    911911                        }
    912912                        ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    913913                        if ( ! refType ) {
    914                                 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl );
     914                                throw SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
    915915                        }
    916916                        if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    917                                 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
     917                                throw SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
    918918                        }
    919919                }
     
    950950
    951951                        sub.apply( inst );
    952                         if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst );
    953                         if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst );
     952                        if ( args.size() < params->size() ) throw SemanticError( inst, "Too few type arguments in generic type " );
     953                        if ( args.size() > params->size() ) throw SemanticError( inst, "Too many type arguments in generic type " );
    954954                }
    955955        }
Note: See TracChangeset for help on using the changeset viewer.