diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 245dd63373731cecfe15bece492e54c10d82325c..6bcb749e8b86552f47a9b725f40b9a4cb6a26f98 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -15605,6 +15605,13 @@ parser_symbol_add(struct cbl_field_t *new_var ) */ + if( new_var->type == FldPointer ) + { + assert(new_var->data.capacity == 8); + assert(new_var->data.digits == 0); + } + + if( new_var && new_var->type == FldIndex ) { // For a FldIndex, we force some things. Do it here so that @@ -15933,6 +15940,10 @@ parser_symbol_add(struct cbl_field_t *new_var ) // Do nothing here; it gets handled during the constructor for // cblc_field_t::initial } + else if( new_var->type == FldPointer ) + { + length_of_initial_string = new_var->data.capacity; + } else if( new_var->attr & hex_encoded_e ) { length_of_initial_string = new_var->data.capacity; @@ -15942,11 +15953,10 @@ parser_symbol_add(struct cbl_field_t *new_var ) // This is an ordinary string length_of_initial_string = strlen(new_var->data.initial) + 1; } - else + else { - // We were handed a null pointer, so turn that into an empty string: - length_of_initial_string = 2; - new_var->data.initial = "\0\0"; + // We have something that doesn't have a data.initial pointer + length_of_initial_string = 0; } if( new_var->type == FldAlphaEdited) @@ -16302,6 +16312,12 @@ parser_symbol_add(struct cbl_field_t *new_var ) next_field, build_int_cst_type(SIZE_T, figconst) ); } + else if( length_of_initial_string == 0 ) + { + CONSTRUCTOR_APPEND_ELT( CONSTRUCTOR_ELTS(constr), + next_field, + null_pointer_node ); + } else { CONSTRUCTOR_APPEND_ELT( CONSTRUCTOR_ELTS(constr), diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc index 997ded0e29214b07a3a4f887d16816975f3c3964..fe7a4b54f56062554d06a2b44e96943d0527e83e 100644 --- a/gcc/cobol/symbols.cc +++ b/gcc/cobol/symbols.cc @@ -1781,6 +1781,8 @@ symbol_table_init(void) { // Be warned that ZEROS plays for both sides. It is defined here as // quoted, but in context it can be the value zero at run-time. Yes, it // is an annoyance. + static char zeroes_for_null_pointer[8] = {0,0,0,0,0,0,0,0}; + static cbl_field_t constants[] = { { 0, FldLiteralA, FldInvalid, space_value_e | constq, 0, 0, 0, nonarray, 0, "SPACE", {1,1,0,0, " \0\xFF", NULL, { NULL }, { NULL } }, NULL }, @@ -1796,7 +1798,7 @@ symbol_table_init(void) { { 0, FldLiteral, FldInvalid, quote_value_e | constq , 0, 0, 0, nonarray, 0, "QUOTES",{1,1,0,0, "\"\0\xFF", NULL, { NULL }, { NULL } }, NULL }, { 0, FldPointer, FldPointer, constq , 0, 0, 0, nonarray, 0, - "NULLS",{8,8,16,0, NULL, NULL, { NULL }, { NULL } }, NULL }, + "NULLS",{8,8,0,0, zeroes_for_null_pointer, NULL, { NULL }, { NULL } }, NULL }, }; for( struct cbl_field_t *f = constants; f < constants + COUNT_OF(constants); f++ ) { diff --git a/libgcobol/constants.cc b/libgcobol/constants.cc index 7b00eebfaeef8f6bfd19fdc6a2377a1761eb0dfa..ee61dda2f444136123b136ba15aa8959dbe5c87c 100644 --- a/libgcobol/constants.cc +++ b/libgcobol/constants.cc @@ -231,10 +231,10 @@ struct cblc_field_t __gg__quotes = { .rdigits = 0 , }; -unsigned char __gg__data_nulls[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}; +unsigned char __gg__data_nulls[8] = {0,0,0,0,0,0,0,0}; struct cblc_field_t __gg__nulls = { .data = __gg__data_nulls , - .capacity = 16 , + .capacity = 8 , .offset = 0 , .name = "NULLS" , .picture = "" , @@ -247,7 +247,7 @@ struct cblc_field_t __gg__nulls = { .attr = 0x280 , .type = FldPointer , .level = 0 , - .digits = 32 , + .digits = 0 , .rdigits = 0 , };