Bug 25785 - [4.1/4.2 Regression] gfortran - incorrectly issues an error on tests for optional arguments with assumed length
Summary: [4.1/4.2 Regression] gfortran - incorrectly issues an error on tests for opti...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P5 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 25786
  Show dependency treegraph
 
Reported: 2006-01-13 17:41 UTC by Dale Ranta
Modified: 2006-01-18 18:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-13 17:47:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Ranta 2006-01-13 17:41:35 UTC
gfortran has started erroring on some "present" statements (Absoft and others have no problem with this program and older version of gfortran were also happy with it) -


[dranta:~/tests/gfortran-D] dir% f90 -c present01.f90
[dranta:~/tests/gfortran-D] dir% gfortran -c present01.f90
 In file present01.f90:3

        if (present(data_c1)) then
                   1
Error: The upper bound in the last dimension must appear in the reference to the assumed size array 'data_c1' at (1).
[dranta:~/tests/gfortran-D] dir% cat present01.f90
      subroutine my_sio_file_write_common(data_c1)
        character,   intent(in), optional :: data_c1(*)
        if (present(data_c1)) then
        endif
      end subroutine my_sio_file_write_common


[dranta:~/tests/gfortran-D] dir% gfortran --v
Using built-in specs.
Target: powerpc-apple-darwin8.4.0
Configured with: ../gcc/configure --prefix=/Users/dir/gfortran --enable-languages=c,f95
Thread model: posix
gcc version 4.2.0 20060113 (experimental)
Comment 1 Andrew Pinski 2006-01-13 17:47:59 UTC
Confirmed, this is only with assumed length and not with assumed shape or already known shape.
Comment 2 Dale Ranta 2006-01-13 18:06:17 UTC
It also fails with a "double precision" argument -

[dranta:~/tests/gfortran-D] dir% gfortran -c present02.f90
 In file present02.f90:3

        if (present(data_c1)) then
                   1
Error: The upper bound in the last dimension must appear in the reference to the assumed size array 'data_c1' at (1).
[dranta:~/tests/gfortran-D] dir% cat present02.f90
      subroutine my_sio_file_write_common(data_c1)
        double precision,   intent(in), optional :: data_c1(*)
        if (present(data_c1)) then
        endif
      end subroutine my_sio_file_write_common
Comment 3 Andrew Pinski 2006-01-13 18:09:45 UTC
(In reply to comment #2)
> It also fails with a "double precision" argument -

Right it is just an assumed size issue and not related at all to character or any other type.  I might take a look soon.
Comment 4 Andrew Pinski 2006-01-13 18:43:43 UTC
I should note I also found a related bug relating to accepting invalid code for present, see PR 25097.
Comment 5 Dale Ranta 2006-01-17 20:07:32 UTC
This bug has now migrated into the 4.1 tree. Sometime after the 20060104 version Would it not be easier to elminate the offending updates rather than debug them ?
Comment 6 Andrew Pinski 2006-01-17 20:14:22 UTC
(In reply to comment #5)
> This bug has now migrated into the 4.1 tree. Sometime after the 20060104
> version Would it not be easier to elminate the offending updates rather than
> debug them ?

It might but since I only looked at this a little I don't know fully.  Let me add Paul T. to the CC because I feel that his change for PRs 25029,21256, etc. caused this.
Comment 7 Paul Thomas 2006-01-17 22:34:54 UTC
(In reply to comment #5)
> This bug has now migrated into the 4.1 tree. Sometime after the 20060104
> version Would it not be easier to elminate the offending updates rather than
> debug them ?
> 
Yes, it might be easier to eliminate the "offending" updates but you sure as hell will not get me back to look at them again.  I have bent over backwards to get that one right; knowing full well that assumed size was going to be sensitive because of its legacy implication.  I repeatedly posted the patch and its updates on the mailing list so that all the wrinkles would get flagged up.  I will sort out why the intrinsic present is giving this error and will post a patch.  Kindly let me know if there are any other, similar problems.

Paul
Comment 8 Paul Thomas 2006-01-18 05:47:32 UTC
Dale,

I have calmed down a bit now! As I said, I put a lot into trying to get this right; trunk is, of course, experimental and one should reasonably expect problems of this kind to get ironed out on the fly.  That it got to 4.1 is annoying but I did follow the agreed procedure of waiting 1 week between trunk and 4.1 commits.

The patch is trivial and I will submit/commit it in the next 24 hours.

Thanks for reporting this; if there are any other assumed length nasties lurking there, please let me know.

Paul 
Comment 9 Dale Ranta 2006-01-18 14:20:20 UTC
    Paul,

    I am sorry that I upset you. It was completely unintentional.

    Dale.
Comment 10 Paul Thomas 2006-01-18 16:45:34 UTC
Subject: Re:  [4.1/4.2 Regression] gfortran - incorrectly
 issues an error on tests for optional arguments with assumed length

Dale,

>
>    I am sorry that I upset you. It was completely unintentional.
>
>  
>
I upset myself; you were just the trigger!

Paul

Comment 11 Paul Thomas 2006-01-18 18:55:07 UTC
Subject: Bug 25785

Author: pault
Date: Wed Jan 18 18:55:01 2006
New Revision: 109899

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109899
Log:
2006-01-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20869
	PR fortran/20875
	PR fortran/25024
	* symbol.c (check_conflict): Add pointer valued elemental
	functions and internal procedures with the external attribute
	to the list of conflicts.
	(gfc_add_attribute): New catch-all function to perform the
	checking of symbol attributes for attribute declaration
	statements.
	* decl.c (attr_decl1): Call gfc_add_attribute for each of -
	(gfc_match_external, gfc_match_intent, gfc_match_intrinsic,
	gfc_match_pointer, gfc_match_dimension, gfc_match_target):
	Remove spurious calls to checks in symbol.c.  Set the
	attribute directly and use the call to attr_decl() for
	checking.
	* gfortran.h:  Add prototype for gfc_add_attribute.

	PR fortran/25785
	* resolve.c (resolve_function): Exclude PRESENT from assumed size
	argument checking. Replace strcmp's with comparisons with generic
	codes.

2006-01-18  Paul Thomas  <pault@gcc.gnu.org>
	    Steven G. Kargl  <kargls@comcast.net>

	PR fortran/20869
	* gfortran.dg/intrinsic_external_1.f90: New test.

	PR fortran/20875.
	* gfortran.dg/elemental_pointer_1.f90: New test.

	PR fortran/25024
	* gfortran.dg/external_procedures_1.f90: New test.

	PR fortran/25785
	gfortran.dg/assumed_present.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/assumed_present.f90
    trunk/gcc/testsuite/gfortran.dg/elemental_pointer_1.f90
    trunk/gcc/testsuite/gfortran.dg/external_procedures_1.f90
    trunk/gcc/testsuite/gfortran.dg/intrinsic_external_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog

Comment 12 Paul Thomas 2006-01-18 18:56:48 UTC
Subject: Bug 25785

Author: pault
Date: Wed Jan 18 18:56:43 2006
New Revision: 109900

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109900
Log:
2006-01-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20869
	PR fortran/20875
	PR fortran/25024
	* symbol.c (check_conflict): Add pointer valued elemental
	functions and internal procedures with the external attribute
	to the list of conflicts.
	(gfc_add_attribute): New catch-all function to perform the
	checking of symbol attributes for attribute declaration
	statements.
	* decl.c (attr_decl1): Call gfc_add_attribute for each of -
	(gfc_match_external, gfc_match_intent, gfc_match_intrinsic,
	gfc_match_pointer, gfc_match_dimension, gfc_match_target):
	Remove spurious calls to checks in symbol.c.  Set the
	attribute directly and use the call to attr_decl() for
	checking.
	* gfortran.h:  Add prototype for gfc_add_attribute.

	PR fortran/25785
	* resolve.c (resolve_function): Exclude PRESENT from assumed size
	argument checking. Replace strcmp's with comparisons with generic
	codes.

2006-01-18  Paul Thomas  <pault@gcc.gnu.org>
	    Steven G. Kargl  <kargls@comcast.net>

	PR fortran/20869
	* gfortran.dg/intrinsic_external_1.f90: New test.

	PR fortran/20875.
	* gfortran.dg/elemental_pointer_1.f90: New test.

	PR fortran/25024
	* gfortran.dg/external_procedures_1.f90: New test.

	PR fortran/25785
	gfortran.dg/assumed_present.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/assumed_present.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/elemental_pointer_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/external_procedures_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intrinsic_external_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/decl.c
    branches/gcc-4_1-branch/gcc/fortran/gfortran.h
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/symbol.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 13 Paul Thomas 2006-01-18 18:59:48 UTC
Fixed on trunk and 4.1

Thanks and sorry

Paul