User account creation filtered due to spam.

Bug 33334 - User-defined type as function result: use-assocciated not accepted
Summary: User-defined type as function result: use-assocciated not accepted
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: accepts-invalid, rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-09-07 15:01 UTC by Tobias Burnus
Modified: 2007-10-02 07:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-09-22 18:42:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-09-07 15:01:22 UTC
(Split off from PR 31154.)
The following is accepted but invalid (without using "IMPORT t"):

module x
 implicit none
 type t
   integer :: i
 end type t
 interface
   type(t) function bar()
   end function
 end interface
end
Comment 1 Tobias Burnus 2007-09-08 08:09:53 UTC
This probably needs the same technique as PR31229 / PR31154.

The following program is valid, but rejected by gfortran (also if one does not rename the symbol):

  func%i = 5
     1
Error: Derived type 'z' at (1) is being used before it is defined
a.f90:7.21:

type(z) function func()
                    1
Error: The derived type 'func' at (1) is of type 'z', which has not been defined


module x
 type t
   integer :: i
 end type t
end module x

type(z) function func()
  use x, only: z=>t
  func%i = 5
end function func


This program is accepted by NAG f95, g95, ifort, openf95 and sunf95.
Comment 2 Paul Thomas 2007-09-21 20:55:53 UTC
I've just sorted PRs 33337 and 33376, so I'll tunr back to these fellows next.

This is confirmed, of course.

Paul
Comment 3 Paul Thomas 2007-09-22 18:42:21 UTC
I'll do all of these, having started.

Paul
Comment 4 Paul Thomas 2007-10-02 07:17:31 UTC
Subject: Bug 33334

Author: pault
Date: Tue Oct  2 07:17:01 2007
New Revision: 128948

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128948
Log:
2007-10-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31154
	PR fortran/31229
	PR fortran/33334
	* decl.c : Declare gfc_function_kind_locs and
	gfc_function_type_locus.
	(gfc_match_kind_spec): Add second argument kind_expr_only.
	Store locus before trying to match the expression. If the
	current state corresponds to a function declaration and there
	is no match to the expression, read to the parenthesis, return
	kind = -1, dump the expression and return.
	(gfc_match_type_spec): Renamed from match_type_spec and all
	references changed.  If an interface or an external function,
	store the locus, set kind = -1 and return.  Otherwise, if kind
	is already = -1, use gfc_find_symbol to try to find a use
	associated or imported type.
	match.h : Prototype for gfc_match_type_spec.
	* parse.c (match_deferred_characteristics): New function.
	(parse_spec): If in a function, statement is USE or IMPORT
	or DERIVED_DECL and the function kind=-1, call
	match_deferred_characteristics.  If kind=-1 at the end of the
	specification expressions, this is an error.
	* parse.h : Declare external gfc_function_kind_locs and
	gfc_function_type_locus.

2007-10-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31154
	PR fortran/31229
	PR fortran/33334
	* gfortran.dg/function_kinds_1.f90: New test.
	* gfortran.dg/function_kinds_2.f90: New test.
	* gfortran.dg/derived_function_interface_1.f90: Correct illegal
	use association into interfaces.


Added:
    trunk/gcc/testsuite/gfortran.dg/function_kinds_1.f90
    trunk/gcc/testsuite/gfortran.dg/function_kinds_2.f90
    trunk/gcc/testsuite/gfortran.dg/intent_out_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/match.h
    trunk/gcc/fortran/parse.c
    trunk/gcc/fortran/parse.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90

Comment 5 Paul Thomas 2007-10-02 07:24:10 UTC
Fixed on trunk

Paul