re PR fortran/33037 (TRANSFER should warn on mismatched sizes)

2007-09-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33037
        * simplify.c (gfc_simplify_transfer): Warn if source size
        is smaller than result size.

2007-09-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33037
        * gfortran.dg/transfer_check_1.f90: New.

From-SVN: r128646
This commit is contained in:
Tobias Burnus 2007-09-21 12:21:29 +02:00
parent 91fe042485
commit 92ebaacd31
4 changed files with 25 additions and 1 deletions

View File

@ -1,7 +1,13 @@
2007-09-21 Tobias Burnus <burnus@net-b.de>
PR fortran/33037
* simplify.c (gfc_simplify_transfer): Warn if source size
is smaller than result size.
2007-09-20 Asher Langton <langton2@llnl.gov>
PR fortran/20441
* gfortran.h : Add init_local_* enums and init_flag_* flags to
* gfortran.h : Add init_local_* enums and init_flag_* flags to
gfc_option_t.
* lang.opt: Add -finit-local-zero, -finit-real, -finit-integer,
-finit-character, and -finit-logical flags.

View File

@ -4059,6 +4059,11 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size)
result_size = result_elt_size;
}
if (source_size < result_size)
gfc_warning("Intrinsic TRANSFER at %L has partly undefined result: "
"source size %ld < result size %ld", &source->where,
(long) source_size, (long) result_size);
/* Allocate the buffer to store the binary version of the source. */
buffer_size = MAX (source_size, result_size);
buffer = (unsigned char*)alloca (buffer_size);

View File

@ -1,3 +1,8 @@
2007-09-21 Tobias Burnus <burnus@net-b.de>
PR fortran/33037
* gfortran.dg/transfer_check_1.f90: New.
2007-09-20 Asher Langton <langton2@llnl.gov>
PR fortran/20441

View File

@ -0,0 +1,8 @@
! { dg-do compile }
! PR fortran/33037
!
print *, transfer('x', 0, 20) ! { dg-warning "has partly undefined result" }
print *, transfer(1_1, 0) ! { dg-warning "has partly undefined result" }
print *, transfer([1_2,2_2], 0)
print *, transfer([1_2,2_2], 0_8) ! { dg-warning "has partly undefined result" }
end