Changeset 1f370451 for src/SymTab


Ignore:
Timestamp:
Nov 27, 2017, 2:38:37 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
c029f4d
Parents:
a7caf3d
Message:

Carry attributes through typedefs

Location:
src/SymTab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    ra7caf3d r1f370451  
    372372                                continue;
    373373                        }
    374                         memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ) );
     374                        // do not carry over field's attributes to parameter type
     375                        Type * paramType = field->get_type()->clone();
     376                        deleteAll( paramType->attributes );
     377                        paramType->attributes.clear();
     378                        // add a parameter corresponding to this field
     379                        memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) );
    375380                        FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    376381                        makeFieldCtorBody( aggregateDecl->members.begin(), aggregateDecl->members.end(), ctor );
     
    503508                                break;
    504509                        }
    505                         memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, field->get_type()->clone(), nullptr ) );
     510                        // do not carry over field's attributes to parameter type
     511                        Type * paramType = field->get_type()->clone();
     512                        deleteAll( paramType->attributes );
     513                        paramType->attributes.clear();
     514                        // add a parameter corresponding to this field
     515                        memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) );
    506516                        FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    507517                        ObjectDecl * srcParam = strict_dynamic_cast<ObjectDecl *>( ctor->type->parameters.back() );
  • src/SymTab/Validate.cc

    ra7caf3d r1f370451  
    201201                Declaration * postmutate( TraitDecl * contextDecl );
    202202
     203                void premutate( FunctionType * ftype );
     204
    203205          private:
    204206                template<typename AggDecl>
     
    214216                TypeDeclMap typedeclNames;
    215217                int scopeLevel;
     218                bool inFunctionType = false;
    216219        };
    217220
     
    725728                        Type *ret = def->second.first->base->clone();
    726729                        ret->get_qualifiers() |= typeInst->get_qualifiers();
     730                        // attributes are not carried over from typedef to function parameters/return values
     731                        if ( ! inFunctionType ) {
     732                                ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
     733                        } else {
     734                                deleteAll( ret->attributes );
     735                                ret->attributes.clear();
     736                        }
    727737                        // place instance parameters on the typedef'd type
    728738                        if ( ! typeInst->parameters.empty() ) {
     
    901911        Declaration *EliminateTypedef::postmutate( TraitDecl * traitDecl ) {
    902912                return handleAggregate( traitDecl );
     913        }
     914
     915        void EliminateTypedef::premutate( FunctionType * ) {
     916                GuardValue( inFunctionType );
     917                inFunctionType = true;
    903918        }
    904919
Note: See TracChangeset for help on using the changeset viewer.