Changeset d3d54b3 for src/AST/Expr.cpp


Ignore:
Timestamp:
Feb 5, 2025, 1:45:29 PM (2 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
ab94c37
Parents:
92aeae1
Message:

Eliminate warnings due to sizeof returning type inconsistent with %zu. Fix #269.

Test

nowarn/printf-sizeof

: Activate direct test of the bug.

Tests

alloc-ERROR
extension
array-collections/dimexpr-match-c-ERRS

: Accommodate incidental changes in error-message text or generated code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/AST/Expr.cpp

    r92aeae1 rd3d54b3  
    2626#include "Stmt.hpp"
    2727#include "Type.hpp"
     28#include "Util.hpp"                // for TranslationDeps
    2829#include "TypeSubstitution.hpp"
    2930#include "Common/Utility.hpp"
     
    281282
    282283SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * t )
    283 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {}
     284: Expr( loc, ast::TranslationDeps::getSizeType() ), type( t ) {}
    284285
    285286// --- AlignofExpr
    286287
    287288AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t )
    288 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {}
     289: Expr( loc, ast::TranslationDeps::getSizeType() ), type( t ) {}
    289290
    290291// --- CountofExpr
    291292
    292293CountofExpr::CountofExpr( const CodeLocation & loc, const Type * t )
    293 : Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), type( t ) {}
     294: Expr( loc, ast::TranslationDeps::getSizeType() ), type( t ) {}
    294295
    295296// --- OffsetofExpr
    296297
    297298OffsetofExpr::OffsetofExpr( const CodeLocation & loc, const Type * ty, const DeclWithType * mem )
    298 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( ty ), member( mem ) {
     299: Expr( loc, ast::TranslationDeps::getSizeType() ), type( ty ), member( mem ) {
    299300        assert( type );
    300301        assert( member );
     
    305306OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty )
    306307: Expr( loc, new ArrayType{
    307         new BasicType{ BasicKind::LongUnsignedInt }, nullptr, FixedLen, DynamicDim }
     308        ast::TranslationDeps::getSizeType(), nullptr, FixedLen, DynamicDim }
    308309), type( ty ) {
    309310        assert( type );
Note: See TracChangeset for help on using the changeset viewer.