Bug 41369 - Empty derived-type wrongly rejected as function return type
Summary: Empty derived-type wrongly rejected as function return type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-09-16 07:20 UTC by Tobias Burnus
Modified: 2009-12-10 21:05 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-09-16 07:20:17 UTC
(Motivated but independent from http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/817234ccd2b3ae1b#)

The following program is rejected in gfortran until one adds a component. I agree that it is not particularly useful but I think it is standard conform.

In any case the error message is bogus:


type(t) function foo()
1
Error: The type for function 'foo' at (1) is not accessible


module m
 type t
 end type t
end module

type(t) function foo()
  use m
  foo = t()
end function foo
Comment 1 Dominique d'Humieres 2009-09-16 08:45:08 UTC
The test is also rejected by g95 and ifort, the latter gives:

error #7128: A derived-type-def must have at least one component-def-stmt.
Comment 2 Tobias Burnus 2009-09-16 10:33:35 UTC
(In reply to comment #1)
> The test is also rejected by g95 and ifort, the latter gives:
> error #7128: A derived-type-def must have at least one component-def-stmt.

I did not claim that I have a valid Fortran 95 program - in Fortran 2003 it is allowed.

And ifort 11.1 compiles it (well, at least without the empty structure constructor which gives a "not yet implemented" error.).
Comment 3 Daniel Franke 2009-12-10 21:04:03 UTC
Subject: Bug 41369

Author: dfranke
Date: Thu Dec 10 21:03:40 2009
New Revision: 155141

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155141
Log:
2009-12-10  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/41369
	* parse.c (match_deferred_characteristics): Removed check for empty
	types in function return values.

2009-12-10  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/41369
	* gfortran.dg/func_derived_5.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/func_derived_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Daniel Franke 2009-12-10 21:05:01 UTC
Fixed in trunk. Closing.