From 36032710357e5af5f3743c46c29c457e2b04ed05 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 25 May 2007 06:34:10 +0000 Subject: [PATCH] re PR fortran/32047 (ICE (segfault) for pure function without argument) 2007-05-25 Paul Thomas PR fortran/32047 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Change order in logic under EXPR_FUNCTION to handle functions with no arguments. 2007-05-25 Paul Thomas PR fortran/32047 * gfortran.dg/result_in_spec_2.f90: New test. From-SVN: r125057 --- gcc/fortran/ChangeLog | 7 ++++++ gcc/fortran/trans-expr.c | 10 ++++----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/result_in_spec_2.f90 | 31 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/result_in_spec_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f0275ef..7ceb0ee 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2007-05-25 Paul Thomas + + PR fortran/32047 + * trans-expr.c (gfc_apply_interface_mapping_to_expr): Change + order in logic under EXPR_FUNCTION to handle functions with + no arguments. + 2007-05-23 Jerry DeLisle PR fortran/31716 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 527a44b..e621a6a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1653,12 +1653,12 @@ gfc_apply_interface_mapping_to_expr (gfc_interface_mapping * mapping, break; case EXPR_FUNCTION: - if (expr->value.function.actual->expr->expr_type == EXPR_VARIABLE - && gfc_apply_interface_mapping_to_expr (mapping, - expr->value.function.actual->expr) - && expr->value.function.esym == NULL + if (expr->value.function.esym == NULL && expr->value.function.isym != NULL - && expr->value.function.isym->generic_id == GFC_ISYM_LEN) + && expr->value.function.isym->generic_id == GFC_ISYM_LEN + && expr->value.function.actual->expr->expr_type == EXPR_VARIABLE + && gfc_apply_interface_mapping_to_expr (mapping, + expr->value.function.actual->expr)) { gfc_expr *new_expr; new_expr = gfc_copy_expr (expr->value.function.actual->expr->ts.cl->length); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3997e2d..47f40df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-05-25 Paul Thomas + + PR fortran/32047 + * gfortran.dg/result_in_spec_2.f90: New test. + 2007-05-24 Kaveh R. Ghazi * gcc.dg/torture/builtin-math-4.c: Fix dg-xfail-if. diff --git a/gcc/testsuite/gfortran.dg/result_in_spec_2.f90 b/gcc/testsuite/gfortran.dg/result_in_spec_2.f90 new file mode 100644 index 0000000..cffa230 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/result_in_spec_2.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +! Tests the fix for PR32047, in which the null agument +! function for the character length would cause an ICE. +! +! Contributed by Tobias Burnus +! +module test1 + implicit none +contains + character(f()) function test2() result(r) + interface + pure function f() + integer f + end function f + end interface + r = '123' + end function test2 +end module test1 + +pure function f() + integer :: f + f = 3 +end function f + +program test + use test1 + implicit none + if(len (test2()) /= 3) call abort () + if(test2() /= '123') call abort () +end program test +! { dg-final { cleanup-modules "test1" } } -- 2.7.4