aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/check.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2012-08-14 12:22:06 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2012-08-14 12:22:06 +0200
commit2e60cfaa2b1de4fac1fe56be8273f4c547ae74dd (patch)
treea0adac75a16f1e2a307ff509d4ff79517429a89d /gcc/fortran/check.c
parent343c5d461c4f8659b1acc74a99ae78ac234b8ba7 (diff)
downloadgcc-2e60cfaa2b1de4fac1fe56be8273f4c547ae74dd.zip
gcc-2e60cfaa2b1de4fac1fe56be8273f4c547ae74dd.tar.gz
gcc-2e60cfaa2b1de4fac1fe56be8273f4c547ae74dd.tar.bz2
re PR fortran/54234 (-Wconversion or -Wconversion-extra should warn for CMPLX(dp,dp))
2012-08-14 Tobias Burnus <burnus@net-b.de> PR fortran/54234 * check.c (gfc_check_cmplx): Add -Wconversion warning when converting higher-precision REAL to default-precision CMPLX without kind= parameter. 2012-08-14 Tobias Burnus <burnus@net-b.de> PR fortran/54234 * gfortran.dg/warn_conversion_4.f90: New. From-SVN: r190378
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r--gcc/fortran/check.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index c5bf79b..2235b52 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1278,6 +1278,17 @@ gfc_check_cmplx (gfc_expr *x, gfc_expr *y, gfc_expr *kind)
if (kind_check (kind, 2, BT_COMPLEX) == FAILURE)
return FAILURE;
+ if (!kind && gfc_option.gfc_warn_conversion
+ && x->ts.type == BT_REAL && x->ts.kind > gfc_default_real_kind)
+ gfc_warning_now ("Conversion from %s to default-kind COMPLEX(%d) at %L "
+ "might loose precision, consider using the KIND argument",
+ gfc_typename (&x->ts), gfc_default_real_kind, &x->where);
+ else if (y && !kind && gfc_option.gfc_warn_conversion
+ && y->ts.type == BT_REAL && y->ts.kind > gfc_default_real_kind)
+ gfc_warning_now ("Conversion from %s to default-kind COMPLEX(%d) at %L "
+ "might loose precision, consider using the KIND argument",
+ gfc_typename (&y->ts), gfc_default_real_kind, &y->where);
+
return SUCCESS;
}