Commit 5dbe01a1 by Bernd Edlinger Committed by Bernd Edlinger

primary.c (match_real_constant): Remove shadowing local vars.

2019-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * primary.c (match_real_constant): Remove shadowing local vars.
        Rename local vars.  Fix undefined behavior in loop termination.
        (gfc_convert_to_structure_constructor): Rename local var.

From-SVN: r276518
parent 2925cad2
2019-10-03 Bernd Edlinger <bernd.edlinger@hotmail.de>
* primary.c (match_real_constant): Remove shadowing local vars.
Rename local vars. Fix undefined behavior in loop termination.
(gfc_convert_to_structure_constructor): Rename local var.
2019-10-03 Thomas Koenig <tkoenig@gcc.gnu.org> 2019-10-03 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84487 PR fortran/84487
......
...@@ -789,16 +789,17 @@ done: ...@@ -789,16 +789,17 @@ done:
if (warn_conversion_extra) if (warn_conversion_extra)
{ {
mpfr_t r; mpfr_t r;
char *c, *p; char *c1;
bool did_break; bool did_break;
c = strchr (buffer, 'e'); c1 = strchr (buffer, 'e');
if (c == NULL) if (c1 == NULL)
c = buffer + strlen(buffer); c1 = buffer + strlen(buffer);
did_break = false; did_break = false;
for (p = c - 1; p >= buffer; p--) for (p = c1; p > buffer;)
{ {
p--;
if (*p == '.') if (*p == '.')
continue; continue;
...@@ -3099,21 +3100,21 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c ...@@ -3099,21 +3100,21 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
&& actual->expr->ts.type == BT_CHARACTER && actual->expr->ts.type == BT_CHARACTER
&& actual->expr->expr_type == EXPR_CONSTANT) && actual->expr->expr_type == EXPR_CONSTANT)
{ {
ptrdiff_t c, e; ptrdiff_t c, e1;
c = gfc_mpz_get_hwi (this_comp->ts.u.cl->length->value.integer); c = gfc_mpz_get_hwi (this_comp->ts.u.cl->length->value.integer);
e = actual->expr->value.character.length; e1 = actual->expr->value.character.length;
if (c != e) if (c != e1)
{ {
ptrdiff_t i, to; ptrdiff_t i, to;
gfc_char_t *dest; gfc_char_t *dest;
dest = gfc_get_wide_string (c + 1); dest = gfc_get_wide_string (c + 1);
to = e < c ? e : c; to = e1 < c ? e1 : c;
for (i = 0; i < to; i++) for (i = 0; i < to; i++)
dest[i] = actual->expr->value.character.string[i]; dest[i] = actual->expr->value.character.string[i];
for (i = e; i < c; i++) for (i = e1; i < c; i++)
dest[i] = ' '; dest[i] = ' ';
dest[c] = '\0'; dest[c] = '\0';
...@@ -3122,11 +3123,11 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c ...@@ -3122,11 +3123,11 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
actual->expr->value.character.length = c; actual->expr->value.character.length = c;
actual->expr->value.character.string = dest; actual->expr->value.character.string = dest;
if (warn_line_truncation && c < e) if (warn_line_truncation && c < e1)
gfc_warning_now (OPT_Wcharacter_truncation, gfc_warning_now (OPT_Wcharacter_truncation,
"CHARACTER expression will be truncated " "CHARACTER expression will be truncated "
"in constructor (%ld/%ld) at %L", (long int) c, "in constructor (%ld/%ld) at %L", (long int) c,
(long int) e, &actual->expr->where); (long int) e1, &actual->expr->where);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment