Changeset dcbb03b for src/SymTab


Ignore:
Timestamp:
Mar 1, 2018, 9:29:03 AM (8 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:
1f37ed02
Parents:
b002261 (diff), 446ffa3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/SymTab
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rb002261 rdcbb03b  
    2424#include <vector>                  // for vector
    2525
    26 #include "AddVisit.h"              // for addVisit
    2726#include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign
    2827#include "Common/PassVisitor.h"    // for PassVisitor
     
    332331                        definitions.push_back( dcl );
    333332                        indexer.addId( dcl );
    334                 } catch ( SemanticError err ) {
     333                } catch ( SemanticErrorException err ) {
    335334                        // okay if decl does not resolve - that means the function should not be generated
    336335                        delete dcl;
  • src/SymTab/Indexer.cc

    rb002261 rdcbb03b  
    443443                        // isomorphic to C type-compatibility, which it may not be.
    444444                        if ( hasIncompatibleCDecl( name, mangleName, scope ) ) {
    445                                 throw SemanticError( decl, "conflicting overload of C function " );
     445                                SemanticError( decl, "conflicting overload of C function " );
    446446                        }
    447447                } else {
    448448                        // Check that a Cforall declaration doesn't override any C declaration
    449449                        if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    450                                 throw SemanticError( decl, "Cforall declaration hides C function " );
     450                                SemanticError( decl, "Cforall declaration hides C function " );
    451451                        }
    452452                }
     
    463463        void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) {
    464464                // default handling of conflicts is to raise an error
    465                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, baseExpr );
     465                addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, baseExpr );
    466466        }
    467467
    468468        void Indexer::addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt ) {
    469469                // default handling of conflicts is to raise an error
    470                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, nullptr, deleteStmt );
     470                addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, nullptr, deleteStmt );
    471471        }
    472472
     
    477477                        return true;
    478478                } else {
    479                         throw SemanticError( added, "redeclaration of " );
     479                        SemanticError( added, "redeclaration of " );
    480480                }
    481481        }
     
    504504                        return false;
    505505                } else if ( ! added->get_members().empty() ) {
    506                         throw SemanticError( added, "redeclaration of " );
     506                        SemanticError( added, "redeclaration of " );
    507507                } // if
    508508                return true;
     
    603603                                        if ( dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t ) ) {
    604604                                                Expression * base = expr->clone();
    605                                                 ResolvExpr::referenceToRvalueConversion( base );
     605                                                ResolvExpr::Cost cost = ResolvExpr::Cost::zero; // xxx - carry this cost into the indexer as a base cost?
     606                                                ResolvExpr::referenceToRvalueConversion( base, cost );
    606607                                                addMembers( t->getAggr(), new MemberExpr( dwt, base ), handleConflicts );
    607608                                        }
     
    705706        }
    706707
    707         Expression * Indexer::IdData::combine() const {
     708        Expression * Indexer::IdData::combine( ResolvExpr::Cost & cost ) const {
    708709                Expression * ret = nullptr;
    709710                if ( baseExpr ) {
    710711                        Expression * base = baseExpr->clone();
    711                         ResolvExpr::referenceToRvalueConversion( base );
     712                        ResolvExpr::referenceToRvalueConversion( base, cost );
    712713                        ret = new MemberExpr( id, base );
    713714                        // xxx - this introduces hidden environments, for now remove them.
  • src/SymTab/Indexer.h

    rb002261 rdcbb03b  
    2323#include "SynTree/Visitor.h"  // for Visitor
    2424#include "SynTree/SynTree.h"  // for AST nodes
     25
     26namespace ResolvExpr {
     27class Cost;
     28}
    2529
    2630namespace SymTab {
     
    5155                        IdData( DeclarationWithType * id, Expression * baseExpr, BaseSyntaxNode * deleteStmt ) : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ) {}
    5256
    53                         Expression * combine() const;
     57                        Expression * combine( ResolvExpr::Cost & cost ) const;
    5458                };
    5559
  • src/SymTab/Validate.cc

    rb002261 rdcbb03b  
    6060#include "Parser/LinkageSpec.h"        // for C
    6161#include "ResolvExpr/typeops.h"        // for typesCompatible
    62 #include "SymTab/AddVisit.h"           // for addVisit
    6362#include "SymTab/Autogen.h"            // for SizeType
    6463#include "SynTree/Attribute.h"         // for noAttributes, Attribute
     
    361360                        // the only case in which "void" is valid is where it is the only one in the list
    362361                        if ( containsVoid && ( nvals > 1 || isVarArgs ) ) {
    363                                 throw SemanticError( func, "invalid type void in function type " );
     362                                SemanticError( func, "invalid type void in function type " );
    364363                        }
    365364
     
    402401                for ( Expression * param : inst->parameters ) {
    403402                        if ( ! dynamic_cast< TypeExpr * >( param ) ) {
    404                                 throw SemanticError( inst, "Expression parameters for generic types are currently unsupported: " );
     403                                SemanticError( inst, "Expression parameters for generic types are currently unsupported: " );
    405404                        }
    406405                }
     
    502501                TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name );
    503502                if ( ! traitDecl ) {
    504                         throw SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
     503                        SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
    505504                } // if
    506505                if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) {
    507                         throw SemanticError( traitInst, "incorrect number of trait parameters: " );
     506                        SemanticError( traitInst, "incorrect number of trait parameters: " );
    508507                } // if
    509508                traitInst->baseTrait = traitDecl;
     
    513512                        TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) );
    514513                        if ( ! expr ) {
    515                                 throw SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );
     514                                SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );
    516515                        }
    517516                        if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) {
     
    619618                                bool isVoid = fixFunction( assertion );
    620619                                if ( isVoid ) {
    621                                         throw SemanticError( node, "invalid type void in assertion of function " );
     620                                        SemanticError( node, "invalid type void in assertion of function " );
    622621                                } // if
    623622                        } // for
     
    663662                // were cast to void.
    664663                if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) {
    665                         throw SemanticError( returnStmt, "Non-void function returns no values: " );
     664                        SemanticError( returnStmt, "Non-void function returns no values: " );
    666665                }
    667666        }
     
    704703                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    705704                                if ( ! rtt ) {
    706                                         throw SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );
     705                                        SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );
    707706                                }
    708707                                rtt->get_parameters().clear();
     
    742741                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
    743742                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
    744                                 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
     743                                SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    745744                        }
    746745                        // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs
     
    749748                        // to fix this corner case likely outweighs the utility of allowing it.
    750749                        if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) {
    751                                 throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
     750                                SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    752751                        }
    753752                } else {
     
    898897                if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
    899898                        if ( params.size() == 0 ) {
    900                                 throw SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
     899                                SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
    901900                        }
    902901                        ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    903902                        if ( ! refType ) {
    904                                 throw SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
     903                                SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
    905904                        }
    906905                        if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    907                                 throw SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
     906                                SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
    908907                        }
    909908                }
     
    940939
    941940                        sub.apply( inst );
    942                         if ( args.size() < params->size() ) throw SemanticError( inst, "Too few type arguments in generic type " );
    943                         if ( args.size() > params->size() ) throw SemanticError( inst, "Too many type arguments in generic type " );
     941                        if ( args.size() < params->size() ) SemanticError( inst, "Too few type arguments in generic type " );
     942                        if ( args.size() > params->size() ) SemanticError( inst, "Too many type arguments in generic type " );
    944943                }
    945944        }
Note: See TracChangeset for help on using the changeset viewer.