Changeset b4cd03b7 for src/GenPoly


Ignore:
Timestamp:
Feb 5, 2016, 12:27:21 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
4789f44
Parents:
5721a6d
Message:

fix many warnings from gcc by adding appropriate casts to adapter parameters

Location:
src/GenPoly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r5721a6d rb4cd03b7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 14:53:08 2015
    13 // Update Count     : 217
     12// Last Modified On : Fri Feb 05 12:23:10 2016
     13// Update Count     : 280
    1414//
    1515
     
    137137                        virtual Expression *mutate( MemberExpr *memberExpr );
    138138                };
    139                
     139
    140140                /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
    141141                class Pass3 : public PolyMutator {
     
    176176                                                seenIntrinsic = false; // break on this line when debugging for end of prelude
    177177                                        }
    178                                        
     178
    179179                                        *i = dynamic_cast< Declaration* >( (*i)->acceptMutator( mutator ) );
    180180                                        assert( *i );
     
    284284                                }
    285285                        }
    286                        
     286
    287287                        if ( functionDecl->get_statements() ) {         // empty routine body ?
    288288                                doBeginScope();
     
    318318                                        findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter );
    319319                                } // for
    320                                
     320
    321321                                AdapterMap & adapters = Pass1::adapters.top();
    322322                                for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
     
    371371                Expression *Pass1::makeOffsetArray( StructInstType *ty ) {
    372372                        std::list< Declaration* > &baseMembers = ty->get_baseStruct()->get_members();
    373                        
     373
    374374                        // make a new temporary array
    375375                        Type *offsetType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     
    395395                        return new VariableExpr( arrayTemp );
    396396                }
    397                
     397
    398398                void Pass1::passTypeVars( ApplicationExpr *appExpr, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
    399399                        // pass size/align for type variables
     
    491491                        }
    492492                }
    493                
     493
    494494                Type *Pass1::replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone ) {
    495495                        if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     
    529529                        std::string adapterName = makeAdapterName( mangleName );
    530530
    531                         appExpr->get_args().push_front( appExpr->get_function() );
     531                        // cast adaptee to void (*)(), since it may have any type inside a polymorphic function
     532                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     533                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    532534                        appExpr->set_function( new NameExpr( adapterName ) );
    533535
     
    557559                }
    558560
     561                /// cast parameters to polymorphic functions so that types are replaced with
     562                /// void * if they are type parameters in the formal type.
     563                /// this gets rid of warnings from gcc.
    559564                void addCast( Expression *&actual, Type *formal, const TyVarMap &tyVars ) {
    560                         Type *newType = formal->clone();
    561                         std::list< FunctionType *> functions;
    562                         // instead of functions needing adapters, this really ought to look for
    563                         // any function mentioning a polymorphic type
    564                         findAndReplaceFunction( newType, functions, tyVars, needsAdapter );
    565                         if ( ! functions.empty() ) {
     565                        Type * newType = formal->clone();
     566                        if ( getFunctionType( newType ) ) {
     567                                newType = ScrubTyVars::scrub( newType, tyVars );
    566568                                actual = new CastExpr( actual, newType );
    567                         } else {
    568                                 delete newType;
    569569                        } // if
    570570                }
  • src/GenPoly/FindFunction.cc

    r5721a6d rb4cd03b7  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FindFunction.cc -- 
     7// FindFunction.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 07:35:48 2015
    13 // Update Count     : 1
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Feb 05 12:22:20 2016
     13// Update Count     : 6
    1414//
    1515
     
    1919#include "SynTree/Visitor.h"
    2020
     21#include "ScrubTyVars.h"
     22
    2123namespace GenPoly {
    2224        class FindFunction : public Mutator {
    2325          public:
    2426                FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
    25  
     27
    2628                virtual Type *mutate( FunctionType *functionType );
    2729                virtual Type *mutate( PointerType *pointerType );
     
    6668                        functions.push_back( functionType );
    6769                        if ( replaceMode ) {
    68                                 ret = new FunctionType( Type::Qualifiers(), true );
     70                                // replace type parameters in function type with void*
     71                                ret = ScrubTyVars::scrub( functionType->clone(), tyVars );
    6972                        } // if
    7073                } // if
Note: See TracChangeset for help on using the changeset viewer.