Changeset 10dc6908


Ignore:
Timestamp:
Nov 13, 2017, 10:38:12 AM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9d06142
Parents:
20eacb7
git-author:
Rob Schluntz <rschlunt@…> (11/13/17 10:38:05)
git-committer:
Rob Schluntz <rschlunt@…> (11/13/17 10:38:12)
Message:

Add cast to _Destructor's dtor initializer to silence warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r20eacb7 r10dc6908  
    10551055                                                                // function->get_statements()->push_back( callStmt );
    10561056
    1057                                                                 // Destructor _dtor0 = { &b.a1, _destroy_A };
     1057                                                                // Destructor _dtor0 = { &b.a1, (void (*)(void *)_destroy_A };
    10581058                                                                std::list< Statement * > stmtsToAdd;
    10591059
     
    10651065                                                                Expression * dtorExpr = new VariableExpr( getDtorFunc( thisParam, callStmt, stmtsToAdd ) );
    10661066
    1067                                                                 ObjectDecl * destructor = ObjectDecl::newObject( memberDtorNamer.newName(), new StructInstType( Type::Qualifiers(), dtorStruct ), new ListInit( { new SingleInit( thisExpr ), new SingleInit( dtorExpr ) } ) );
     1067                                                                // cast destructor pointer to void (*)(void *), to silence GCC incompatible pointer warnings
     1068                                                                FunctionType * dtorFtype = new FunctionType( Type::Qualifiers(), false );
     1069                                                                dtorFtype->parameters.push_back( ObjectDecl::newObject( "", new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), nullptr ) );
     1070                                                                Type * dtorType = new PointerType( Type::Qualifiers(), dtorFtype );
     1071
     1072                                                                ObjectDecl * destructor = ObjectDecl::newObject( memberDtorNamer.newName(), new StructInstType( Type::Qualifiers(), dtorStruct ), new ListInit( { new SingleInit( thisExpr ), new SingleInit( new CastExpr( dtorExpr, dtorType ) ) } ) );
    10681073                                                                function->statements->push_front( new DeclStmt( noLabels, destructor ) );
    10691074                                                                destructor->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( dtorStructDestroy ) } ) );
Note: See TracChangeset for help on using the changeset viewer.