Changeset 8a0a64d9 for src


Ignore:
Timestamp:
Nov 28, 2017, 11:49:12 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:
36982fc, 6c2ba38, d5a52cc
Parents:
8a78dd3 (diff), 8eb348a (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
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r8a78dd3 r8a0a64d9  
    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/ParseNode.h

    r8a78dd3 r8a0a64d9  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 23 18:11:22 2017
    13 // Update Count     : 821
     12// Last Modified On : Mon Nov 27 17:33:35 2017
     13// Update Count     : 824
    1414//
    1515
     
    292292        DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
    293293  public:
     294        DeclarationNode * get_last() { return (DeclarationNode *)ParseNode::get_last(); }
     295
    294296        struct Variable_t {
    295297//              const std::string * name;
  • src/Parser/TypeData.cc

    r8a78dd3 r8a0a64d9  
    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

    r8a78dd3 r8a0a64d9  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 26 11:36:36 2017
    13 // Update Count     : 2969
     12// Last Modified On : Mon Nov 27 17:23:35 2017
     13// Update Count     : 2992
    1414//
    1515
     
    13641364                        $$ = $3->addQualifiers( $1 )->addQualifiers( $2 );
    13651365                }
    1366         | cfa_function_declaration pop ',' push identifier_or_type_name
    1367                 {
    1368                         typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
    1369                         $$ = $1->appendList( $1->cloneType( $5 ) );
     1366        | cfa_function_declaration pop ',' push identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')'
     1367                {
     1368                        // Append the return type at the start (left-hand-side) to each identifier in the list.
     1369                        DeclarationNode * ret = new DeclarationNode;
     1370                        ret->type = maybeClone( $1->type->base );
     1371                        $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr, true ) );
    13701372                }
    13711373        ;
     
    24162418                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    24172419                        typedefTable.leaveScope();
    2418                         $$ = $1->addFunctionBody( $3 );
     2420                        // Add the function body to the last identifier in the function definition list, i.e., foo3:
     2421                        //   [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; }
     2422                        $1->get_last()->addFunctionBody( $3 );
     2423                        $$ = $1;
    24192424                }
    24202425        | declaration_specifier function_declarator with_clause_opt compound_statement
  • src/SymTab/Autogen.cc

    r8a78dd3 r8a0a64d9  
    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

    r8a78dd3 r8a0a64d9  
    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/Makefile.am

    r8a78dd3 r8a0a64d9  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Oct 10 14:04:40 2017
    14 ## Update Count     : 47
     13## Last Modified On : Mon Nov 27 21:34:33 2017
     14## Update Count     : 48
    1515###############################################################################
    1616
     
    118118        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    119119
     120functions: functions.c @CFA_BINDIR@/@CFA_NAME@
     121        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
     122
    120123KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
    121124        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
  • src/tests/Makefile.in

    r8a78dd3 r8a0a64d9  
    871871        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    872872
     873functions: functions.c @CFA_BINDIR@/@CFA_NAME@
     874        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
     875
    873876KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
    874877        ${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
  • src/tests/functions.c

    r8a78dd3 r8a0a64d9  
    1010// Created On       : Wed Aug 17 08:39:58 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:40:52 2016
    13 // Update Count     : 1
     12// Last Modified On : Mon Nov 27 18:08:54 2017
     13// Update Count     : 11
    1414//
    1515
     
    6666// Cforall extensions
    6767
    68 [] f( );
     68// [] f( );
    6969[int] f( );
    70 [] f(int);
     70// [] f(int);
    7171[int] f(int);
    72 [] f( ) {}
     72// [] f( ) {}
    7373[int] f( ) {}
    74 [] f(int) {}
     74// [] f(int) {}
    7575[int] f(int) {}
    7676
    7777[int x] f( );
    78 [] f(int x);
    79 [int x] f(int x);
    80 [int x] f( ) {}
    81 [] f(int x) {}
    82 [int x] f(int x) {}
     78// [] f(int x);
     79//[int x] f(int x);
     80//[int x] f( ) {}
     81// [] f(int x) {}
     82//[int x] f(int x) {}
    8383
    8484[int, int x] f( );
    85 [] f(int, int x);
     85// [] f(int, int x);
    8686[int, int x] f(int, int x);
    8787[int, int x] f( ) {}
    88 [] f(int, int x) {}
     88// [] f(int, int x) {}
    8989[int, int x] f(int, int x) {}
    9090
    9191[int, int x, int] f( );
    92 [] f(int, int x, int);
     92// [] f(int, int x, int);
    9393[int, int x, int] f(int, int x, int);
    9494[int, int x, int] f( ) {}
    95 [] f(int, int x, int) {}
     95// [] f(int, int x, int) {}
    9696[int, int x, int] f(int, int x, int) {}
    9797
    9898[int, int x, * int y] f( );
    99 [] f(int, int x, * int y);
     99// [] f(int, int x, * int y);
    100100[int, int x, * int y] f(int, int x, * int y);
    101101[int, int x, * int y] f( ) {}
    102 [] f(int, int x, * int y) {}
     102// [] f(int, int x, * int y) {}
    103103[int, int x, * int y] f(int, int x, * int y) {}
    104104
    105 [ int ] f11( int ), f12;  // => int f11( int ), f12( int );
     105// function prototypes
     106
     107[ int ] f11( int ), f12();  // => int f11( int ), f12( void );
     108
     109const double bar1(), bar2( int ), bar3( double );               // C version
     110[const double] foo(), foo( int ), foo( double ) { return 3.0; } // CFA version
     111struct S { int i; };
     112[S] rtn( int ) {}
     113
    106114
    107115[int] f(
     
    109117        [int](int)
    110118        ) {
    111         int (*(*p)[][10])[][3];
     119        int (*(*pc)[][10])[][3];
    112120        * [][10] * [][3] int p;
    113121        * [] * [int](int) p;
  • src/tests/polymorphism.c

    r8a78dd3 r8a0a64d9  
    8989                // ensure that the size of aggregates with polymorphic members
    9090                // matches the size of the aggregates in a monomorphic context
    91                 assertf( struct_size(x, y) == sizeof(S), "struct size differs in polymorphic context." );
    92                 assertf( union_size(x, y) == sizeof(U), "union size differs in polymorphic context." );
     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) {
Note: See TracChangeset for help on using the changeset viewer.