Ignore:
Timestamp:
Feb 3, 2025, 1:27:20 PM (2 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
dfe8f78
Parents:
59fdd0d
Message:

Eliminate libcfa-build warnings of missing int-to-pointer casts.

Replace a zero_t variable use with literal 0 when it's an argument to an intrinsic and we're generating final C code. Partially revert e0330d2cd1a. Such intrinsics are initialization/assignment of pointers; using the variable implies a missing cast, while using literal 0 needs no cast.

CodeGenerator?.hpp
CodeGenerator?.cpp

Put attibute unused on all zero_t/one_t object decls. It is needed on those whose uses are rewritten by the rule above.

Generate.cpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/CodeGen/Generate.cpp

    r59fdd0d r7959e56  
    4646                }
    4747        };
     48
     49        struct ZeroOneObjectHider final {
     50                ast::ObjectDecl const * postvisit( ast::ObjectDecl const * decl ) {
     51                        if ( decl->type.as<ast::ZeroType>() || decl->type.as<ast::OneType>() ) {
     52                                ast::ObjectDecl * mutDecl = ast::mutate( decl );
     53                                mutDecl->attributes.push_back( new ast::Attribute( "unused" ) );
     54                                return mutDecl;
     55                        }
     56                        return decl;
     57                }
     58        };
    4859} // namespace
    4960
     
    5263        erase_if( translationUnit.decls, shouldClean );
    5364        ast::Pass<TreeCleaner>::run( translationUnit );
     65        ast::Pass<ZeroOneObjectHider>::run( translationUnit );
    5466
    5567        ast::Pass<CodeGenerator> cgv( os,
Note: See TracChangeset for help on using the changeset viewer.