diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc index d81a7f4796ebdc6cfa13bb9086677fe923598744..c7f437198f987e2ef3d5499200b16be7d81cc8d4 100644 --- a/gcc/cobol/except.cc +++ b/gcc/cobol/except.cc @@ -287,7 +287,8 @@ symbol_declaratives_add( size_t program, char achBlob[32]; sprintf(achBlob, "_DECLARATIVE_BLOB%d_", blob_count++); - cbl_field_data_t data = { .memsize = len, .capacity = len, + cbl_field_data_t data = { .memsize = capacity_cast(len), + .capacity = capacity_cast(len), .initial = reinterpret_cast<char*>(blob), .picture = reinterpret_cast<char*>(blob) }; cbl_field_t field = { 0, FldBlob, FldInvalid, constant_e, diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index f7fce3fe07b8ab0062bc2a85522876a4a8115430..00b687a22dca0b88eb474274e3dbf55b248c05c6 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -158,18 +158,11 @@ yyerrorvl( int line, const char *filename, const char fmt[], ... ) { va_end(ap); } -static uint32_t -capacity_cast( size_t size ) { - uint32_t len = static_cast<uint32_t>(size); - assert(len == size); - return len; -} - const char * consistent_encoding_check( const char input[] ) { cbl_field_t faux = { .type = FldAlphanumeric, - .data = { .capacity = capacity_cast(strlen(input)), .initial = input } + .data = { .capacity = capacity_cast(strlen(input)), .initial = input } }; auto s = faux.internalize(); diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h index e316718b8b6a8beeaa7bf63a917ff1ab0159fbed..8cb5c6d4ce19a97437847fa7852d9ac015beb9f8 100644 --- a/gcc/cobol/symbols.h +++ b/gcc/cobol/symbols.h @@ -460,6 +460,13 @@ struct cbl_field_data_t { } }; +static inline uint32_t +capacity_cast( size_t size ) { + uint32_t len = static_cast<uint32_t>(size); + assert(len == size); + return len; +} + struct cbl_occurs_bounds_t { // lower = upper = 0 for a non-table // lower = upper = occurs for a fixed table