User account creation filtered due to spam.

Bug 34471 - Wrong precedence of kinds in typespecs.
Summary: Wrong precedence of kinds in typespecs.
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: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-12-14 22:14 UTC by Tobias Burnus
Modified: 2008-01-17 10:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-08 12:58:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-12-14 22:14:22 UTC
The following program should print "8" and not "4".
Related to PR 34431.

module m
  implicit none
  integer, parameter :: it = 8
end module m


program main
  implicit none
  integer, parameter :: it = 4
  integer :: i
  i = test()
contains
  integer(it) function test()
     use m
     print *, kind(test)
     test = kind(test)
  end function test
end program main
Comment 1 Paul Thomas 2008-01-08 12:58:04 UTC
This is fixed in a patch that I am working on that sorts out the whole business of function characteristics in one go.

Paul
Comment 2 Paul Thomas 2008-01-17 07:19:52 UTC
Subject: Bug 34471

Author: pault
Date: Thu Jan 17 07:19:04 2008
New Revision: 131592

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

	PR fortran/34429
	PR fortran/34431
	PR fortran/34471
	* decl.c : Remove gfc_function_kind_locus and
	gfc_function_type_locus. Add gfc_matching_function.
	(match_char_length): If matching a function and the length
	does not match, return MATCH_YES and try again later.
	(gfc_match_kind_spec): The same.
	(match_char_kind): The same.
	(gfc_match_type_spec): The same for numeric and derived types.
	(match_prefix): Rename as gfc_match_prefix.
	(gfc_match_function_decl): Except for function valued character
	lengths, defer applying kind, type and charlen info until the
	end of specification block.
	gfortran.h (gfc_statement): Add ST_GET_FCN_CHARACTERISTICS.
	parse.c (decode_specification_statement): New function.
	(decode_statement): Call it when a function has kind = -1. Set
	and reset gfc_matching function, as function statement is being
	matched.
	(match_deferred_characteristics): Simplify with a single call
	to gfc_match_prefix. Do appropriate error handling. In any
	case, make sure that kind = -1 is reset or corrected.
	(parse_spec): Call above on seeing ST_GET_FCN_CHARACTERISTICS.
	Throw an error if kind = -1 after last specification statement.
	parse.h : Prototype for gfc_match_prefix.

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

	PR fortran/34429
	* gfortran.dg/function_charlen_1.f90: New test.

	PR fortran/34431
	* gfortran.dg/function_types_1.f90: New test.
	* gfortran.dg/function_types_2.f90: New test.

	PR fortran/34471
	* gfortran.dg/function_kinds_4.f90: New test.
	* gfortran.dg/function_kinds_5.f90: New test.

	* gfortran.dg/defined_operators_1.f90: Errors now at function
	declarations.
	* gfortran.dg/private_type_4.f90: The same.
	* gfortran.dg/interface_15.f90: The same.
	* gfortran.dg/elemental_args_check_2.f90: The same.
	* gfortran.dg/auto_internal_assumed.f90: The same.


Added:
    trunk/gcc/testsuite/gfortran.dg/function_charlen_1.f90
    trunk/gcc/testsuite/gfortran.dg/function_kinds_4.f90
    trunk/gcc/testsuite/gfortran.dg/function_kinds_5.f90
    trunk/gcc/testsuite/gfortran.dg/function_types_1.f90
    trunk/gcc/testsuite/gfortran.dg/function_types_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/misc.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/fortran/parse.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
    trunk/gcc/testsuite/gfortran.dg/defined_operators_1.f90
    trunk/gcc/testsuite/gfortran.dg/elemental_args_check_2.f90
    trunk/gcc/testsuite/gfortran.dg/interface_15.f90
    trunk/gcc/testsuite/gfortran.dg/private_type_4.f90

Comment 3 Paul Thomas 2008-01-17 10:00:04 UTC
Fixed on trunk - see PR34429 for some remaining wrinkles.

Paul