Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r175ad32 rd180746  
    1 #include <algorithm>
     1#include <stddef.h>                // for NULL
     2#include <algorithm>               // for find, all_of
     3#include <cassert>                 // for assertf, assert, safe_dynamic_cast
     4#include <iostream>                // for ostream, cerr, endl
     5#include <iterator>                // for back_insert_iterator, back_inserter
     6#include <memory>                  // for __shared_ptr
     7
     8#include "Common/SemanticError.h"  // for SemanticError
     9#include "Common/UniqueName.h"     // for UniqueName
     10#include "Common/utility.h"        // for toString, deleteAll, maybeClone
     11#include "GenPoly/GenPoly.h"       // for getFunctionType
    212#include "InitTweak.h"
    3 #include "SynTree/Visitor.h"
    4 #include "SynTree/Statement.h"
    5 #include "SynTree/Initializer.h"
    6 #include "SynTree/Expression.h"
    7 #include "SynTree/Attribute.h"
    8 #include "GenPoly/GenPoly.h"
    9 #include "ResolvExpr/typeops.h"
     13#include "Parser/LinkageSpec.h"    // for Spec, isBuiltin, Intrinsic
     14#include "ResolvExpr/typeops.h"    // for typesCompatibleIgnoreQualifiers
     15#include "SymTab/Indexer.h"        // for Indexer
     16#include "SynTree/Attribute.h"     // for Attribute
     17#include "SynTree/Constant.h"      // for Constant
     18#include "SynTree/Declaration.h"   // for ObjectDecl, DeclarationWithType
     19#include "SynTree/Expression.h"    // for Expression, UntypedExpr, Applicati...
     20#include "SynTree/Initializer.h"   // for Initializer, ListInit, Designation
     21#include "SynTree/Label.h"         // for Label, noLabels
     22#include "SynTree/Statement.h"     // for CompoundStmt, ExprStmt, BranchStmt
     23#include "SynTree/Type.h"          // for FunctionType, ArrayType, PointerType
     24#include "SynTree/Visitor.h"       // for Visitor, maybeAccept
     25
     26class UntypedValofExpr;
    1027
    1128namespace InitTweak {
     
    170187
    171188                        UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) );
    172                         increment->get_args().push_back( index->clone() );
     189                        increment->get_args().push_back( new AddressExpr( index->clone() ) );
    173190                        *out++ = new ExprStmt( noLabels, increment );
    174191                }
     
    380397                template<typename CallExpr>
    381398                Expression *& callArg( CallExpr * callExpr, unsigned int pos ) {
    382                         if ( pos >= callExpr->get_args().size() ) assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", pos, toString( callExpr ).c_str() );
     399                        if ( pos >= callExpr->get_args().size() ) assertf( false, "asking for argument that doesn't exist. Return NULL/throw exception?" );
    383400                        for ( Expression *& arg : callExpr->get_args() ) {
    384401                                if ( pos == 0 ) return arg;
     
    458475                } else if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
    459476                        return arrayType->get_base();
    460                 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( type ) ) {
    461                         return refType->get_base();
    462477                } else {
    463478                        return NULL;
     
    545560                if ( ftype->get_parameters().size() != 2 ) return 0;
    546561
    547                 Type * t1 = getPointerBase( ftype->get_parameters().front()->get_type() );
     562                Type * t1 = ftype->get_parameters().front()->get_type();
    548563                Type * t2 = ftype->get_parameters().back()->get_type();
    549                 assert( t1 );
    550 
    551                 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( t1, t2, SymTab::Indexer() ) ) {
     564                PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
     565                assert( ptrType );
     566
     567                if ( ResolvExpr::typesCompatibleIgnoreQualifiers( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
    552568                        return function;
    553569                } else {
Note: See TracChangeset for help on using the changeset viewer.