Changeset d3d54b3 for src/AST/Util.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/Util.cpp

    r92aeae1 rd3d54b3  
    2222#include "Common/Utility.hpp"
    2323#include "GenPoly/ScopedSet.hpp"
     24#include "Decl.hpp"
     25#include "Type.hpp"
    2426
    2527#include <vector>
     
    382384}
    383385
     386namespace {
     387        const TranslationUnit * transUnit = 0;
     388}
     389
     390void TranslationDeps::evolve( TranslationUnit & u ) {
     391        transUnit = &u;
     392}
     393
     394const ast::Type * TranslationDeps::getSizeType() {
     395        static const ast::Type * zd_abstract = new TypeInstType{ "size_t", TypeDecl::Kind::Dtype };
     396        static const ast::Type * ld_concrete = new BasicType( BasicKind::LongUnsignedInt );
     397        if ( ! transUnit ) {
     398                // early state
     399                // as if `size_t` in program text were freshly parsed
     400                return zd_abstract;
     401        } else if ( transUnit->global.sizeType ) {
     402                // late state, normal run
     403                // whatever size_t was defined as
     404                return transUnit->global.sizeType;
     405        } else {
     406                // late state, no prelude (-n)
     407                // placeholder: cfa-cpp is being used experimentally, stay out of the way
     408                return ld_concrete;
     409        }
     410}
     411
     412
    384413} // namespace ast
Note: See TracChangeset for help on using the changeset viewer.