aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Dubner <rdubner@symas.com>2025-03-26 16:07:44 -0400
committerRobert Dubner <rdubner@symas.com>2025-03-26 16:32:32 -0400
commit4c05d6d26dbc0e8799325cc1c1a8221b52e7e28e (patch)
treef18396728010a03b1cc1c60e86fef5de68c33be0 /gcc
parent5e897d7e954439c4f0aea1ffa0c18bbea27e3373 (diff)
downloadgcc-4c05d6d26dbc0e8799325cc1c1a8221b52e7e28e.zip
gcc-4c05d6d26dbc0e8799325cc1c1a8221b52e7e28e.tar.gz
gcc-4c05d6d26dbc0e8799325cc1c1a8221b52e7e28e.tar.bz2
cobol: Bring trunk in line with Dubner's test system.
gcc/cobol * genapi.cc: (parser_display_internal): Adjust for E vs e exponent notation. * parse.y: (literal_refmod_valid): Display correct value in error message.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cobol/genapi.cc24
-rw-r--r--gcc/cobol/parse.y4
2 files changed, 24 insertions, 4 deletions
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index dc0bb79..032236b 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -4818,14 +4818,34 @@ parser_display_internal(tree file_descriptor,
if( !p )
{
// Probably INF -INF NAN or -NAN, so ach has our result
+ // Except that real_to_decimal prints -0.0 and 0.0 like that with
+ // no e.
+ if( ach[0] == '0' || ( ach[0] == '-' && ach[1] == '0' ))
+ __gg__remove_trailing_zeroes(ach);
}
else
{
- p += 1;
- int exp = atoi(p);
+ int exp = atoi(p+1);
if( exp >= 6 || exp <= -5 )
{
// We are going to stick with the E notation, so ach has our result
+ // Except that real_to_decimal prints with e notation rather than E
+ // and doesn't guarantee at least two exponent digits.
+ *p = 'E';
+ if( exp < 0 && exp >= -9 )
+ {
+ p[1] = '-';
+ p[2] = '0';
+ p[3] = '0' - exp;
+ p[4] = '\0';
+ }
+ else if( exp >= 0 && exp <= 9 )
+ {
+ p[1] = '+';
+ p[2] = '0';
+ p[3] = '0' + exp;
+ p[4] = '\0';
+ }
}
else if (exp == 0)
{
diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index bad9952..538e56f 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -12856,14 +12856,14 @@ literal_refmod_valid( YYLTYPE loc, const cbl_refer_t& r ) {
if( ! is_literal(refmod.len->field) ) return true;
auto edge = refmod.len->field->as_integer();
if( 0 < edge ) {
- if( --edge < r.field->data.capacity ) return true;
+ if( edge-1 < r.field->data.capacity ) return true;
}
// len < 0 or not: 0 < from + len <= capacity
error_msg(loc, "%s(%s:%zu) out of bounds, "
"size is %u",
r.field->name,
refmod.from->name(),
- size_t(refmod.len->field->data.value_of()),
+ size_t(edge),
static_cast<unsigned int>(r.field->data.capacity) );
return false;
}