From 48b155b991003487a50ac171ba5ca7c3409ad417 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 6 Aug 2011 15:19:45 +0000 Subject: [PATCH] re PR fortran/50004 (ICE in c_ptr_tests_16.f90) 2011-08-06 Thomas Koenig PR fortran/50004 * target-memory.c (gfc_target_expr-size): Don't clobber typespec for derived types. * simplify.c (gfc_simplify_transfer): Don't calculate source_size twice. From-SVN: r177527 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/simplify.c | 2 -- gcc/fortran/target-memory.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5567ffd7838..81eec356b50 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2011-08-06 Thomas Koenig + + PR fortran/50004 + * target-memory.c (gfc_target_expr-size): Don't clobber typespec + for derived types. + * simplify.c (gfc_simplify_transfer): Don't calculate source_size + twice. + 2011-08-05 Thomas Koenig PR fortran/37211 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index e4ffc3b477f..13a9c5147c0 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6048,8 +6048,6 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size) && gfc_array_size (source, &tmp) == FAILURE) gfc_internal_error ("Failure getting length of a constant array."); - source_size = gfc_target_expr_size (source); - /* Create an empty new expression with the appropriate characteristics. */ result = gfc_get_constant_expr (mold->ts.type, mold->ts.kind, &source->where); diff --git a/gcc/fortran/target-memory.c b/gcc/fortran/target-memory.c index 025bccf0b0c..63878959b47 100644 --- a/gcc/fortran/target-memory.c +++ b/gcc/fortran/target-memory.c @@ -120,8 +120,14 @@ gfc_target_expr_size (gfc_expr *e) case BT_HOLLERITH: return e->representation.length; case BT_DERIVED: - type = gfc_typenode_for_spec (&e->ts); - return int_size_in_bytes (type); + { + /* Determine type size without clobbering the typespec for ISO C + binding types. */ + gfc_typespec ts; + ts = e->ts; + type = gfc_typenode_for_spec (&ts); + return int_size_in_bytes (type); + } default: gfc_internal_error ("Invalid expression in gfc_target_expr_size."); return 0; -- 2.30.2