Changes in / [c0d00b6:c6e2c18]


Ignore:
Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rc0d00b6 rc6e2c18  
    855855                        DeclarationWithType *adapteeDecl = adapterType->get_parameters().front();
    856856                        adapteeDecl->set_name( "_adaptee" );
     857                        // do not carry over attributes to real type parameters/return values
     858                        for ( DeclarationWithType * dwt : realType->parameters ) {
     859                                deleteAll( dwt->get_type()->attributes );
     860                                dwt->get_type()->attributes.clear();
     861                        }
     862                        for ( DeclarationWithType * dwt : realType->returnVals ) {
     863                                deleteAll( dwt->get_type()->attributes );
     864                                dwt->get_type()->attributes.clear();
     865                        }
    857866                        ApplicationExpr *adapteeApp = new ApplicationExpr( new CastExpr( new VariableExpr( adapteeDecl ), new PointerType( Type::Qualifiers(), realType ) ) );
    858867                        Statement *bodyStmt;
  • src/Parser/TypeData.cc

    rc0d00b6 rc6e2c18  
    792792
    793793
    794 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
     794NamedTypeDecl * buildSymbolic( const TypeData * td, std::list< Attribute * > attributes, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
    795795        assert( td->kind == TypeData::Symbolic );
    796796        NamedTypeDecl * ret;
     
    803803        buildList( td->symbolic.params, ret->get_parameters() );
    804804        buildList( td->symbolic.assertions, ret->get_assertions() );
     805        ret->base->attributes.splice( ret->base->attributes.end(), attributes );
    805806        return ret;
    806807} // buildSymbolic
     
    866867                return buildEnum( td, attributes, linkage );
    867868        } else if ( td->kind == TypeData::Symbolic ) {
    868                 return buildSymbolic( td, name, scs, linkage );
     869                return buildSymbolic( td, attributes, name, scs, linkage );
    869870        } else {
    870871                return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName );
  • src/Parser/parser.yy

    rc0d00b6 rc6e2c18  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 20 09:45:36 2017
    13 // Update Count     : 2945
     12// Last Modified On : Sun Nov 26 11:36:36 2017
     13// Update Count     : 2969
    1414//
    1515
     
    345345%type<en> type_list
    346346
    347 %type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list
     347%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
    348348%type<decl> type_specifier type_specifier_nobody
    349349
     
    379379//   `---'                                              matches start of TYPEGENname '('
    380380// Must be:
    381 // Foo( int ) ( *fp )( int );
     381//   Foo( int ) ( *fp )( int );
    382382
    383383// Order of these lines matters (low-to-high precedence).
     
    10581058with_statement:
    10591059        WITH '(' tuple_expression_list ')' statement
    1060                 { $$ = nullptr; }                                                               // FIX ME
     1060                { throw SemanticError("With clause is currently unimplemented."); $$ = nullptr; } // FIX ME
    10611061        ;
    10621062
     
    10641064mutex_statement:
    10651065        MUTEX '(' argument_expression_list ')' statement
    1066                 { $$ = nullptr; }                                                               // FIX ME
     1066                { throw SemanticError("Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME
    10671067        ;
    10681068
     
    12801280        c_declaration pop ';'
    12811281        | cfa_declaration pop ';'                                                       // CFA
     1282        | STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
     1283                { throw SemanticError("Static assert is currently unimplemented."); $$ = nullptr; }     // FIX ME
    12821284        ;
    12831285
     
    15871589        | ATOMIC
    15881590                { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
    1589         | FORALL '('
     1591        | forall
     1592        ;
     1593
     1594forall:
     1595        FORALL '('
    15901596                {
    15911597                        typedefTable.enterScope();
     
    23742380                        $$ = $2;
    23752381                }
     2382        | forall '{' external_definition_list '}'                       // CFA, namespace
    23762383        ;
    23772384
     
    23992406with_clause_opt:
    24002407        // empty
    2401                 { $$ = nullptr; }                                                               // FIX ME
     2408                { $$ = nullptr; }
    24022409        | WITH '(' tuple_expression_list ')'
    2403                 { $$ = nullptr; }                                                               // FIX ME
     2410                { throw SemanticError("With clause is currently unimplemented."); $$ = nullptr; } // FIX ME
    24042411        ;
    24052412
     
    24182425                        $$ = $2->addFunctionBody( $4 )->addType( $1 );
    24192426                }
     2427                // handles default int return type, OBSOLESCENT (see 1)
    24202428        | type_qualifier_list function_declarator with_clause_opt compound_statement
    24212429                {
     
    24242432                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
    24252433                }
     2434                // handles default int return type, OBSOLESCENT (see 1)
    24262435        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    24272436                {
     
    24302439                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
    24312440                }
     2441                // handles default int return type, OBSOLESCENT (see 1)
    24322442        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    24332443                {
     
    24452455                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addType( $1 );
    24462456                }
     2457                // handles default int return type, OBSOLESCENT (see 1)
    24472458        | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24482459                {
     
    24512462                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 );
    24522463                }
    2453 
    2454                 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
     2464                // handles default int return type, OBSOLESCENT (see 1)
    24552465        | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24562466                {
     
    24592469                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 );
    24602470                }
     2471                // handles default int return type, OBSOLESCENT (see 1)
    24612472        | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24622473                {
  • src/SymTab/Autogen.cc

    rc0d00b6 rc6e2c18  
    375375                                continue;
    376376                        }
    377                         memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ) );
     377                        // do not carry over field's attributes to parameter type
     378                        Type * paramType = field->get_type()->clone();
     379                        deleteAll( paramType->attributes );
     380                        paramType->attributes.clear();
     381                        // add a parameter corresponding to this field
     382                        memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) );
    378383                        FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    379384                        makeFieldCtorBody( aggregateDecl->members.begin(), aggregateDecl->members.end(), ctor );
     
    506511                                break;
    507512                        }
    508                         memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, field->get_type()->clone(), nullptr ) );
     513                        // do not carry over field's attributes to parameter type
     514                        Type * paramType = field->get_type()->clone();
     515                        deleteAll( paramType->attributes );
     516                        paramType->attributes.clear();
     517                        // add a parameter corresponding to this field
     518                        memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) );
    509519                        FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    510520                        ObjectDecl * srcParam = strict_dynamic_cast<ObjectDecl *>( ctor->type->parameters.back() );
  • src/SymTab/Validate.cc

    rc0d00b6 rc6e2c18  
    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
  • src/tests/polymorphism.c

    rc0d00b6 rc6e2c18  
    4747        S s;
    4848        s.i = i;
    49         assert(s.i == i);
     49        assertf(s.i == i, "struct operation fails in polymorphic context.");
    5050
    5151        B b;
     
    7373        {
    7474                // test aggregates with polymorphic members
    75                 typedef uint32_t x_type;
    76                 typedef uint64_t y_type;
     75                typedef __attribute__((aligned(8))) uint32_t x_type;
     76                typedef __attribute__((aligned(8))) uint64_t y_type;
    7777
    7878                x_type x = 3;
     
    8989                // ensure that the size of aggregates with polymorphic members
    9090                // matches the size of the aggregates in a monomorphic context
    91                 assert( struct_size(x, y) == sizeof(S) );
    92                 assert( union_size(x, y) == sizeof(U) );
     91                size_t ssz = struct_size(x, y);
     92                size_t usz = union_size(x, y);
     93                assertf( ssz == sizeof(S), "struct size differs in polymorphic context: %zd / %zd", ssz, sizeof(S));
     94                assertf( usz == sizeof(U), "union size differs in polymorphic context: %zd / %zd", usz, sizeof(U));
    9395
    9496                y_type ?=?(y_type & this, zero_t) {
     
    111113                u.f2 = 0;
    112114                u.f1 = x;
    113                 assert(ret == u.f2);
     115                assertf(ret == u.f2, "union operation fails in polymorphic context.");
    114116        }
    115117}
Note: See TracChangeset for help on using the changeset viewer.