Bug 36233 - [4.3/4.4 Regression] Array valued actual procedure argument rejected
Summary: [4.3/4.4 Regression] Array valued actual procedure argument rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.3.1
Assignee: Paul Thomas
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-05-13 20:39 UTC by Paul Thomas
Modified: 2008-05-22 20:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-14 20:44:18


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2008-05-13 20:39:33 UTC
module mod
contains
  function foo (arg)
    integer foo (10)
    integer arg
    foo = arg
  end function
end module

  use mod
  call bar (foo)
contains
  subroutine bar (arg)
    interface
      function arg (x)
        integer arg (10)
        integer x
      end function
    end interface
    print *, arg (10)
  end subroutine
end

produces

test.f90:11.12:

  call bar (foo)
           1
Warning: Actual argument contains too few elements for dummy argument 'arg' (1/10) at (1)
Comment 1 Paul Thomas 2008-05-13 21:34:57 UTC
(In reply to comment #0)
This fixs it and regtests OK

Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c     (revision 134835)
--- gcc/fortran/interface.c     (working copy)
*************** compare_actual_formal (gfc_actual_arglis
*** 1942,1948 ****
  
        actual_size = get_expr_storage_size (a->expr);
        formal_size = get_sym_storage_size (f->sym);
!       if (actual_size != 0 && actual_size < formal_size)
        {
          if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where)
            gfc_warning ("Character length of actual argument shorter "
--- 1942,1950 ----
  
        actual_size = get_expr_storage_size (a->expr);
        formal_size = get_sym_storage_size (f->sym);
!       if (actual_size != 0
!           && actual_size < formal_size
!           && a->expr->ts.type != BT_PROCEDURE)
        {
          if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where)
            gfc_warning ("Character length of actual argument shorter "
Comment 2 Jerry DeLisle 2008-05-14 00:04:12 UTC
OK to commit as simple.
Comment 3 Paul Thomas 2008-05-14 05:15:17 UTC
(In reply to comment #2)
> OK to commit as simple.
> 

Jerry,

In the clear light of day, I think that I need to separate the character and the array checks.  I'll check the standard and try other compilers - once I 'm happy, I'll commit.

Thanks

Paul
Comment 4 Paul Thomas 2008-05-14 20:44:17 UTC
(In reply to comment #3)
> (In reply to comment #2)

> Jerry,
> 
> In the clear light of day, I think that I need to separate the character and
> the array checks.  I'll check the standard and try other compilers - once I 'm
> happy, I'll commit.
> 

It's OK as it is.  Full testcase regtesting now.

Paul
Comment 5 Paul Thomas 2008-05-14 21:33:43 UTC
Subject: Bug 36233

Author: pault
Date: Wed May 14 21:32:53 2008
New Revision: 135307

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135307
Log:
2008-05-14  Paul Thomas  <pault@gcc.gnu.org>

       PR fortran/36233
       * interface.c (compare_actual_formal): Do not check sizes if the
       actual is BT_PROCEDURE.

2008-05-14  Paul Thomas  <pault@gcc.gnu.org>

       PR fortran/36233
       * gfortran.dg/actual_procedure_1.f90: New test


Added:
    trunk/gcc/testsuite/gfortran.dg/actual_procedure_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2008-05-17 07:11:12 UTC
Subject: Bug 36233

Author: pault
Date: Sat May 17 07:10:13 2008
New Revision: 135461

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135461
Log:
2008-05-17  Paul Thomas  <pault@gcc.gnu.org>

	Backport from mainline:
	PR fortran/35756
	PR fortran/35759
	* trans-stmt.c (gfc_trans_where): Tighten up the dependency
	check for calling gfc_trans_where_3.

	PR fortran/35743
	* trans-stmt.c (gfc_trans_where_2): Set the mask size to zero
	if it is calculated to be negative.

	PR fortran/35745
	* trans-stmt.c (gfc_trans_where_3, gfc_trans_where_assign): Set
	ss->where for scalar right hand sides.
	* trans-array.c (gfc_add_loop_ss_code): If ss->where is set do
	not evaluate scalars outside the loop.  Clean up whitespace.
	* trans.h : Add a bitfield 'where' to gfc_ss.

       PR fortran/36233
       * interface.c (compare_actual_formal): Do not check sizes if the
       actual is BT_PROCEDURE.

2008-05-17  Paul Thomas  <pault@gcc.gnu.org>

	Backport from mainline:
	PR fortran/35756
	PR fortran/35759
	* gfortran.dg/where_1.f90: New test.

	PR fortran/35743
	PR fortran/35745
	* gfortran.dg/where_2.f90: New test.

       PR fortran/36233
       * gfortran.dg/actual_procedure_1.f90: New test

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/actual_procedure_1.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/where_1.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/where_2.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/interface.c
    branches/gcc-4_3-branch/gcc/fortran/trans-array.c
    branches/gcc-4_3-branch/gcc/fortran/trans-stmt.c
    branches/gcc-4_3-branch/gcc/fortran/trans.h
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 7 Paul Thomas 2008-05-17 08:20:38 UTC
Fixed on trunk and 4.3.

Thanks for the report.

Paul