Changeset 13099105 for src


Ignore:
Timestamp:
May 23, 2017, 12:20:38 PM (7 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:
8bcaf21
Parents:
2c9ebab (diff), 935315d (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:
5 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r2c9ebab r13099105  
    896896                        Parent::visit( compoundStmt );
    897897
    898                         // add destructors for the current scope that we're exiting
     898                        // add destructors for the current scope that we're exiting, unless the last statement is a return, which
     899                        // causes unreachable code warnings
    899900                        std::list< Statement * > & statements = compoundStmt->get_kids();
    900                         insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( statements ) );
     901                        if ( ! statements.empty() && ! dynamic_cast< ReturnStmt * >( statements.back() ) ) {
     902                                insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( statements ) );
     903                        }
    901904                        reverseDeclOrder.pop_front();
    902905                }
  • src/SymTab/Validate.cc

    r2c9ebab r13099105  
    208208        };
    209209
     210        /// ensure that generic types have the correct number of type arguments
     211        class ValidateGenericParameters : public Visitor {
     212        public:
     213                typedef Visitor Parent;
     214                virtual void visit( StructInstType * inst ) final override;
     215                virtual void visit( UnionInstType * inst ) final override;
     216        };
     217
    210218        class ArrayLength : public Visitor {
    211219        public:
     
    235243                Pass3 pass3( 0 );
    236244                CompoundLiteral compoundliteral;
    237 
    238                 HoistStruct::hoistStruct( translationUnit );
     245                ValidateGenericParameters genericParams;
     246
    239247                EliminateTypedef::eliminateTypedef( translationUnit );
     248                HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order
    240249                ReturnTypeFixer::fix( translationUnit ); // must happen before autogen
    241250                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     251                acceptAll( translationUnit, genericParams );  // check as early as possible - can't happen before LinkReferenceToTypes
    242252                acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist
    243253                VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
     
    829839        }
    830840
     841        template< typename Aggr >
     842        void validateGeneric( Aggr * inst ) {
     843                std::list< TypeDecl * > * params = inst->get_baseParameters();
     844                if ( params != NULL ) {
     845                        std::list< Expression * > & args = inst->get_parameters();
     846                        if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst );
     847                        if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst );
     848                }
     849        }
     850
     851        void ValidateGenericParameters::visit( StructInstType * inst ) {
     852                validateGeneric( inst );
     853                Parent::visit( inst );
     854        }
     855
     856        void ValidateGenericParameters::visit( UnionInstType * inst ) {
     857                validateGeneric( inst );
     858                Parent::visit( inst );
     859        }
     860
    831861        DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) {
    832862                storageClasses = objectDecl->get_storageClasses();
  • src/libcfa/gmp

    r2c9ebab r13099105  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 23:47:36 2017
    13 // Update Count     : 9
     12// Last Modified On : Mon May 22 08:32:39 2017
     13// Update Count     : 13
    1414//
    1515
     
    3535Int ?=?( Int * lhs, long int rhs ) { mpz_set_si( lhs->mpz, rhs ); return *lhs; }
    3636Int ?=?( Int * lhs, unsigned long int rhs ) { mpz_set_ui( lhs->mpz, rhs ); return *lhs; }
    37 //Int ?=?( Int * lhs, const char * rhs ) { if ( mpq_set_str( lhs->mpz, rhs, 0 ) ) abort(); return *lhs; }
     37Int ?=?( Int * lhs, const char * rhs ) { if ( mpz_set_str( lhs->mpz, rhs, 0 ) ) { printf( "invalid string conversion\n" ); abort(); } return *lhs; }
    3838
    3939char ?=?( char * lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
  • src/tests/.expect/64/gmp.txt

    r2c9ebab r13099105  
    44conversions
    55y:97
     6y:12345678901234567890123456789
    67y:3
    78y:-3
     
    2425z:150000000000000000000
    2526z:16666666666666666666
     2716666666666666666666, 2 16666666666666666666, 2
    2628x:16666666666666666666 y:2
    2729
  • src/tests/gmp.c

    r2c9ebab r13099105  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 14:46:50 2017
    13 // Update Count     : 530
     12// Last Modified On : Mon May 22 09:05:09 2017
     13// Update Count     : 538
    1414//
    1515
    1616#include <gmp>
    1717
    18 int main() {
     18int main( void ) {
    1919        sout | "constructors" | endl;
    2020        short int si = 3;
     
    2525        sout | "conversions" | endl;
    2626        y = 'a';
     27        sout | "y:" | y | endl;
     28        y = "12345678901234567890123456789";
    2729        sout | "y:" | y | endl;
    2830        y = si;
     
    6264        z = x / 3;
    6365        sout | "z:" | z | endl;
     66        sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6467        [ x, y ] = div( x, 3 );
    6568        sout | "x:" | x | "y:" | y | endl;
    66 //      sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6769
    6870        sout | endl;
     
    7274        fn = (Int){0}; fn1 = fn;                                                        // 1st case
    7375        sout | (int)0 | fn | endl;
    74         fn = (Int){1}; fn2 = fn1; fn1 = fn;                                     // 2nd case
     76        fn = 1; fn2 = fn1; fn1 = fn;                                            // 2nd case
    7577        sout | 1 | fn | endl;
    76         for ( int i = 2; i <= 200; i += 1 ) {
     78        for ( unsigned int i = 2; i <= 200; i += 1 ) {
    7779                fn = fn1 + fn2; fn2 = fn1; fn1 = fn;                    // general case
    7880                sout | i | fn | endl;
     
    8385        sout | "Factorial Numbers" | endl;
    8486        Int fact;
    85         fact = (Int){1};                                                                        // 1st case
     87        fact = 1;                                                                                       // 1st case
    8688        sout | (int)0 | fact | endl;
    87         for ( int i = 1; i <= 40; i += 1 ) {
     89        for ( unsigned int i = 1; i <= 40; i += 1 ) {
    8890                fact = fact * i;                                                                // general case
    8991                sout | i | fact | endl;
Note: See TracChangeset for help on using the changeset viewer.