diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2006-11-28 05:39:42 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2006-11-28 05:39:42 +0000 |
commit | 7523cace86c3739099763b969614c5cd3eee4994 (patch) | |
tree | cf9511adffd003ae39ceba908801955ac52d8dff /gcc | |
parent | 911a40abe03cc49145102efa3881e129c9d9b528 (diff) | |
download | gcc-7523cace86c3739099763b969614c5cd3eee4994.zip gcc-7523cace86c3739099763b969614c5cd3eee4994.tar.gz gcc-7523cace86c3739099763b969614c5cd3eee4994.tar.bz2 |
re PR fortran/29976 (ICE on optional arg)
2006-11-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29976
* trans-expr.c (gfc_conv_missing_dummy): Remove build_int_const
and replace with cast to type of se->expr of integer_zero_node.
2006-11-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29976
* gfortran.dg/missing_optional_dummy_3.f90
From-SVN: r119273
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/missing_optional_dummy_3.f90 | 32 |
4 files changed, 45 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1db6036..9442f68 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2006-11-28 Paul Thomas <pault@gcc.gnu.org> + PR fortran/29976 + * trans-expr.c (gfc_conv_missing_dummy): Remove build_int_const + and replace with cast to type of se->expr of integer_zero_node. + +2006-11-28 Paul Thomas <pault@gcc.gnu.org> + PR fortran/20880 * resolve.c (resolve_fl_procedure): Error if procedure is ambiguous modified to require attr.referenced. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 8e1dcc13f..d504043 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -153,7 +153,8 @@ gfc_conv_missing_dummy (gfc_se * se, gfc_expr * arg, gfc_typespec ts) present = gfc_conv_expr_present (arg->symtree->n.sym); tmp = build3 (COND_EXPR, TREE_TYPE (se->expr), present, se->expr, - build_int_cst (TREE_TYPE (se->expr), 0)); + fold_convert (TREE_TYPE (se->expr), integer_zero_node)); + tmp = gfc_evaluate_now (tmp, &se->pre); se->expr = tmp; if (ts.type == BT_CHARACTER) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89b0464..5c87db9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2006-11-28 Paul Thomas <pault@gcc.gnu.org> + PR fortran/29976 + * gfortran.dg/missing_optional_dummy_3.f90 + +2006-11-28 Paul Thomas <pault@gcc.gnu.org> + PR fortran/20880 * gfortran.dg/interface_3.f90: Modify errors. diff --git a/gcc/testsuite/gfortran.dg/missing_optional_dummy_3.f90 b/gcc/testsuite/gfortran.dg/missing_optional_dummy_3.f90 new file mode 100644 index 0000000..d330dda --- /dev/null +++ b/gcc/testsuite/gfortran.dg/missing_optional_dummy_3.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! Tests the fix for PR29976, in which the call to CMPLX caused an +! ICE with an optional dummy for the imaginary part. +! +! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> +! +SUBROUTINE pw_sumup (alpha_im) + REAL, INTENT(in), OPTIONAL :: alpha_im + COMPLEX :: my_alpha_c + IF (PRESENT(alpha_im)) THEN + my_alpha_c = CMPLX(0.,alpha_im) + END IF +END SUBROUTINE pw_sumup + +! Check non-intrinsic functions. +SUBROUTINE pw_sumup_2 (alpha_im) + REAL, INTENT(in), OPTIONAL :: alpha_im + COMPLEX :: my_alpha_c + IF (PRESENT(alpha_im)) THEN + my_alpha_c = MY_CMPLX(0.,alpha_im) + END IF +contains + complex function MY_CMPLX (re, im) + real, intent(in) :: re + real, intent(in), optional :: im + if (present (im)) then + MY_CMPLX = cmplx (re, im) + else + MY_CMPLX = cmplx (re, 0.0) + end if + end function MY_CMPLX +END SUBROUTINE pw_sumup_2 |