aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/primary.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2019-01-01 21:19:53 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2019-01-01 21:19:53 +0000
commitcf015ca24045bf34c6f22951d2d190eb31248d21 (patch)
tree9c2c1f6c1a96bb6a3b4bef4e0117071bd257cd0a /gcc/fortran/primary.c
parent730832cd7921eb240793634b86d3d026bba58117 (diff)
downloadgcc-cf015ca24045bf34c6f22951d2d190eb31248d21.zip
gcc-cf015ca24045bf34c6f22951d2d190eb31248d21.tar.gz
gcc-cf015ca24045bf34c6f22951d2d190eb31248d21.tar.bz2
re PR fortran/82743 (uncaught character truncation in derived type initialization)
2019-01-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/82743 * primary.c (gfc_convert_to_structure_constructor): If a character in a constructor is too long, add a warning with -Wcharacter-truncation. 2019-01-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/82743 * gfortran.dg/structure_constructor_16.f90: New test. From-SVN: r267499
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r--gcc/fortran/primary.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index d7bd6d6..19f97d1 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -3074,6 +3074,12 @@ 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)
+ 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);
}
}