Bug 32599 - [ISO C Binding] Accepts character with len /= 1
Summary: [ISO C Binding] Accepts character with len /= 1
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 32630
  Show dependency treegraph
 
Reported: 2007-07-02 22:43 UTC by Tobias Burnus
Modified: 2007-07-12 20:25 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 2007-07-02 22:43:58 UTC
The following two routines are invalid. The length has to be one (I think it needs to be also an initialization expression).
While allowing it for -std=gnu is ok, there should be an error for -std=f2003.

NAG f95 prints:
Error: f.f90, line 5: Argument PATH of BIND(C) procedure DESTROY has assumed CHARACTER length
Error: f.f90, line 11: Argument PATH of BIND(C) procedure CREATE has CHARACTER(LEN=5)



subroutine destroy(path) BIND(C)
  use iso_c_binding
  implicit none
  character(len=*,kind=c_char), intent(IN) :: path
end subroutine destroy

subroutine create(path) BIND(C)
  use iso_c_binding
  implicit none
  character(len=5,kind=c_char), intent(IN) :: path
end subroutine create
end
Comment 1 Tobias Burnus 2007-07-12 19:52:16 UTC
Subject: Bug 32599

Author: burnus
Date: Thu Jul 12 19:52:03 2007
New Revision: 126598

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126598
Log:
2007-07-12  Christopher D. Rickett  <crickett@lanl.gov>

	PR fortran/32599
	* decl.c (verify_c_interop_param): Require character string dummy
	args to BIND(C) procedures to have length 1.
	* resolve.c (resolve_fl_procedure): Modify parameter checking for
	BIND(C) procedures.

	PR fortran/32601
	* resolve.c (gfc_iso_c_func_interface): Verify that a valid
	expression is given as an argument to C_LOC and C_ASSOCIATED.
	* trans-io.c (transfer_expr): Add argument for code block.  Add
	standards check to determine if an error message should be
	reported for printing C_PTR or C_FUNPTR.
	(transfer_array_component): Update arguments to transfer_expr.
	(gfc_trans_transfer): Ditto.

	* symbol.c (gen_cptr_param): Fix whitespace.


2007-07-12  Christopher D. Rickett  <crickett@lanl.gov>

	PR fortran/32599
	* gfortran.dg/32599.f03: New test case.

	PR fortran/32601
	* gfortran.dg/32601.f03: New test case.
	* gfortran.dg/32601_1.f03: Ditto.
	* gfortran.dg/c_ptr_tests_9.f03: Updated dg-options.
	* gfortran.dg/c_ptr_tests_10.f03: Ditto.


Added:
    trunk/gcc/testsuite/gfortran.dg/pr32599.f03
    trunk/gcc/testsuite/gfortran.dg/pr32601.f03
    trunk/gcc/testsuite/gfortran.dg/pr32601_1.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/c_ptr_tests_10.f03
    trunk/gcc/testsuite/gfortran.dg/c_ptr_tests_9.f03

Comment 2 Tobias Burnus 2007-07-12 20:25:05 UTC
Fixed.