Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r3351cc0 rf5c3b6c  
    1212#include "Parser/LinkageSpec.h"    // for Spec, isBuiltin, Intrinsic
    1313#include "ResolvExpr/typeops.h"    // for typesCompatibleIgnoreQualifiers
     14#include "SymTab/Autogen.h"
    1415#include "SymTab/Indexer.h"        // for Indexer
    1516#include "SynTree/Attribute.h"     // for Attribute
     
    9899        class InitExpander::ExpanderImpl {
    99100        public:
    100                 virtual ~ExpanderImpl() = default;
    101101                virtual std::list< Expression * > next( std::list< Expression * > & indices ) = 0;
    102102                virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices ) = 0;
     
    106106        public:
    107107                InitImpl( Initializer * init ) : init( init ) {}
    108                 virtual ~InitImpl() = default;
    109108
    110109                virtual std::list< Expression * > next( __attribute((unused)) std::list< Expression * > & indices ) {
     
    123122        public:
    124123                ExprImpl( Expression * expr ) : arg( expr ) {}
    125                 virtual ~ExprImpl() { delete arg; }
     124
     125                ~ExprImpl() { delete arg; }
    126126
    127127                virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     
    524524        }
    525525
     526        ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) {
     527                static FunctionDecl * assign = nullptr;
     528                if ( ! assign ) {
     529                        // temporary? Generate a fake assignment operator to represent bitwise assignments.
     530                        // This operator could easily exist as a real function, but it's tricky because nothing should resolve to this function.
     531                        TypeDecl * td = new TypeDecl( "T", noStorageClasses, nullptr, TypeDecl::Dtype, true );
     532                        assign = new FunctionDecl( "?=?", noStorageClasses, LinkageSpec::Intrinsic, SymTab::genAssignType( new TypeInstType( noQualifiers, td->name, td ) ), nullptr );
     533                }
     534                if ( dynamic_cast< ReferenceType * >( dst->result ) ) {
     535                        dst = new AddressExpr( dst );
     536                } else {
     537                        dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) );
     538                }
     539                if ( dynamic_cast< ReferenceType * >( src->result ) ) {
     540                        src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
     541                }
     542                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
     543        }
     544
    526545        class ConstExprChecker : public Visitor {
    527546        public:
Note: See TracChangeset for help on using the changeset viewer.