From 5dbe01a1ffe4a3920f81a2b4349d31ec6871b9de Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Thu, 3 Oct 2019 17:03:43 +0000 Subject: [PATCH] primary.c (match_real_constant): Remove shadowing local vars. 2019-10-03 Bernd Edlinger * 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 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/primary.c | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9367322..f7414b6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-03 Bernd Edlinger + + * 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 PR fortran/84487 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 7c65b2e..6b6c7d2 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -789,16 +789,17 @@ done: if (warn_conversion_extra) { mpfr_t r; - char *c, *p; + char *c1; bool did_break; - c = strchr (buffer, 'e'); - if (c == NULL) - c = buffer + strlen(buffer); + c1 = strchr (buffer, 'e'); + if (c1 == NULL) + c1 = buffer + strlen(buffer); did_break = false; - for (p = c - 1; p >= buffer; p--) + for (p = c1; p > buffer;) { + p--; if (*p == '.') continue; @@ -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->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); - e = actual->expr->value.character.length; + e1 = actual->expr->value.character.length; - if (c != e) + if (c != e1) { ptrdiff_t i, to; gfc_char_t *dest; dest = gfc_get_wide_string (c + 1); - to = e < c ? e : c; + to = e1 < c ? e1 : c; for (i = 0; i < to; i++) dest[i] = actual->expr->value.character.string[i]; - for (i = e; i < c; i++) + for (i = e1; i < c; i++) dest[i] = ' '; dest[c] = '\0'; @@ -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.string = dest; - if (warn_line_truncation && c < e) + if (warn_line_truncation && c < e1) gfc_warning_now (OPT_Wcharacter_truncation, "CHARACTER expression will be truncated " "in constructor (%ld/%ld) at %L", (long int) c, - (long int) e, &actual->expr->where); + (long int) e1, &actual->expr->where); } } -- 2.7.4