Changeset 35cc6d4 for src


Ignore:
Timestamp:
Dec 12, 2024, 4:35:32 PM (6 days ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
8ee211d
Parents:
f979f0ba
Message:

Mitigate several unused-declaration warnings in generated code.

See tests/nowarn/unused for the specific cases.

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cpp

    rf979f0ba r35cc6d4  
    8686                        makeLayoutCType()
    8787                ) );
    88                 params.emplace_back( new ast::ObjectDecl(
     88                auto alignParam = new ast::ObjectDecl(
    8989                        sizedParam->location,
    9090                        alignofName( paramName ),
    9191                        makeLayoutCType()
    92                 ) );
     92                );
     93                alignParam->attributes.push_back( new ast::Attribute( "unused" ) );
     94                params.emplace_back( alignParam );
    9395        }
    9496}
  • src/Validate/Autogen.cpp

    rf979f0ba r35cc6d4  
    229229}
    230230
    231 /// Changes the node inside a pointer so that it has the unused attribute.
    232 void addUnusedAttribute( ast::ptr<ast::DeclWithType> & declPtr ) {
    233         ast::DeclWithType * decl = declPtr.get_and_mutate();
     231/// Changes the freshly-constructed (non-const) decl so that it has the unused attribute.
     232ast::ObjectDecl * addUnusedAttribute( ast::ObjectDecl * decl ) {
    234233        decl->attributes.push_back( new ast::Attribute( "unused" ) );
     234        return decl;
    235235}
    236236
     
    373373
    374374ast::ObjectDecl * FuncGenerator::dstParam() const {
    375         return new ast::ObjectDecl( getLocation(), "_dst",
    376                 new ast::ReferenceType( ast::deepCopy( type ) ) );
     375        return addUnusedAttribute(
     376                new ast::ObjectDecl( getLocation(), "_dst",
     377                        new ast::ReferenceType( ast::deepCopy( type ) ) ) );
    377378}
    378379
    379380ast::ObjectDecl * FuncGenerator::srcParam() const {
    380         return new ast::ObjectDecl( getLocation(), "_src",
    381                 ast::deepCopy( type ) );
     381        return addUnusedAttribute(
     382                new ast::ObjectDecl( getLocation(), "_src",
     383                        ast::deepCopy( type ) ) );
    382384}
    383385
     
    673675                // Default constructor and destructor is empty.
    674676                functionDecl->stmts = new ast::CompoundStmt( location );
    675                 // Add unused attribute to parameter to silence warnings.
    676                 addUnusedAttribute( params.front() );
    677677        }
    678678}
     
    747747                // Default constructor and destructor is empty.
    748748                functionDecl->stmts = new ast::CompoundStmt( location );
    749                 // Just add unused attribute to parameter to silence warnings.
    750                 addUnusedAttribute( params.front() );
    751749        }
    752750}
  • src/Validate/CompoundLiteral.cpp

    rf979f0ba r35cc6d4  
    5252                storageClasses
    5353                );
     54        // FIXME: A resolution of #280 could make the unused attribute unnecessary here
     55        //     (let test nowarn/unused decide)
     56        temp->attributes.push_back( new ast::Attribute( "unused" ) );
    5457        declsToAddBefore.push_back( temp );
    5558        return new ast::VariableExpr( expr->location, temp );
  • src/Validate/ImplementEnumFunc.cpp

    rf979f0ba r35cc6d4  
    240240        return genProto(
    241241                "type_name",
    242                 {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
     242                {new ast::ObjectDecl(getLocation(), "", new ast::EnumInstType(decl))},
    243243                {new ast::ObjectDecl(
    244244                        getLocation(), "_ret",
Note: See TracChangeset for help on using the changeset viewer.