Changeset 4ee1efb for src/SymTab


Ignore:
Timestamp:
Oct 26, 2017, 11:23:26 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
136ccd7
Parents:
0b9be4d (diff), 598f50e (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.
git-author:
Rob Schluntz <rschlunt@…> (10/26/17 10:43:08)
git-committer:
Rob Schluntz <rschlunt@…> (10/26/17 11:23:26)
Message:

Merge branch 'fix-missing-cast-warning' into cleanup-dtors

Location:
src/SymTab
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r0b9be4d r4ee1efb  
    314314        void FuncGenerator::generatePrototypes( std::list< FunctionDecl * > & newFuncs ) {
    315315                bool concurrent_type = isConcurrentType();
    316                 for ( const FuncData & data : data ) {
     316                for ( const FuncData & d : data ) {
    317317                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    318                         FunctionType * ftype = data.genType( type, true );
     318                        FunctionType * ftype = d.genType( type, true );
    319319
    320320                        // destructor for concurrent type must be mutex
    321                         if ( concurrent_type && CodeGen::isDestructor( data.fname ) ) {
     321                        if ( concurrent_type && CodeGen::isDestructor( d.fname ) ) {
    322322                                ftype->parameters.front()->get_type()->set_mutex( true );
    323323                        }
    324324
    325                         newFuncs.push_back( genFunc( data.fname, ftype, functionNesting ) );
     325                        newFuncs.push_back( genFunc( d.fname, ftype, functionNesting ) );
    326326                }
    327327        }
  • src/SymTab/FixFunction.cc

    r0b9be4d r4ee1efb  
    5050
    5151        void FixFunction::premutate(FunctionDecl *) { visit_children = false; }
     52        void FixFunction::premutate(ArrayType *) { visit_children = false; }
    5253        void FixFunction::premutate(BasicType *) { visit_children = false; }
    5354        void FixFunction::premutate(PointerType *) { visit_children = false; }
  • src/SymTab/FixFunction.h

    r0b9be4d r4ee1efb  
    3131                Type * postmutate(ArrayType * arrayType);
    3232
     33                void premutate(ArrayType * arrayType);
    3334                void premutate(VoidType * voidType);
    3435                void premutate(BasicType * basicType);
  • src/SymTab/Validate.cc

    r0b9be4d r4ee1efb  
    668668                }
    669669                filter( translationUnit, isTypedef, true );
    670 
    671670        }
    672671
     
    676675                TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() );
    677676                if ( def != typedefNames.end() ) {
    678                         Type *ret = def->second.first->get_base()->clone();
     677                        Type *ret = def->second.first->base->clone();
    679678                        ret->get_qualifiers() |= typeInst->get_qualifiers();
    680679                        // place instance parameters on the typedef'd type
    681                         if ( ! typeInst->get_parameters().empty() ) {
     680                        if ( ! typeInst->parameters.empty() ) {
    682681                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    683682                                if ( ! rtt ) {
    684                                         throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name());
     683                                        throw SemanticError("Cannot apply type parameters to base type of " + typeInst->name);
    685684                                }
    686685                                rtt->get_parameters().clear();
    687                                 cloneAll( typeInst->get_parameters(), rtt->get_parameters() );
    688                                 mutateAll( rtt->get_parameters(), *visitor );  // recursively fix typedefs on parameters
     686                                cloneAll( typeInst->parameters, rtt->parameters );
     687                                mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
    689688                        } // if
    690689                        delete typeInst;
     
    692691                } else {
    693692                        TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() );
    694                         assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->get_name().c_str() );
     693                        assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->name.c_str() );
    695694                        typeInst->set_baseType( base->second );
    696695                } // if
    697696                return typeInst;
     697        }
     698
     699        struct VarLenChecker : WithShortCircuiting {
     700                void previsit( FunctionType * ) { visit_children = false; }
     701                void previsit( ArrayType * at ) {
     702                        isVarLen |= at->isVarLen;
     703                }
     704                bool isVarLen = false;
     705        };
     706
     707        bool isVariableLength( Type * t ) {
     708                PassVisitor<VarLenChecker> varLenChecker;
     709                maybeAccept( t, varLenChecker );
     710                return varLenChecker.pass.isVarLen;
    698711        }
    699712
     
    706719                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
    707720                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
    708                                 throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() );
     721                                throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
     722                        }
     723                        // cannot redefine VLA typedefs
     724                        if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) {
     725                                throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
    709726                        }
    710727                } else {
Note: See TracChangeset for help on using the changeset viewer.