Bug 92004 - [10 Regression] Rejection of different ranks for dummy array argument where actual argument is an element
Summary: [10 Regression] Rejection of different ranks for dummy array argument where a...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.0
: P4 normal
Target Milestone: 10.0
Assignee: Thomas Koenig
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2019-10-05 18:50 UTC by Thomas Koenig
Modified: 2019-10-14 21:39 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-10-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2019-10-05 18:50:39 UTC
From F18, 15.5.2.4 Ordinary dummy variables

14 If the actual argument is a noncoindexed scalar, the
corresponding dummy argument shall be scalar unless the actual
argument is default character, of type character with the
C character kind (18.2.2), or is an element or substring of an
element of an array that is not an assumed-shape, pointer, or
polymorphic array, the dummy argument has assumed-rank, or the
dummy argument is an assumed-type assumed-size array. 

So, this is actually legal:

subroutine baz
  real x(10,10)
  call bar(x(2,2))
  call bar(x)
end subroutine baz
Comment 1 Thomas Koenig 2019-10-14 21:38:06 UTC
Author: tkoenig
Date: Mon Oct 14 21:37:34 2019
New Revision: 276972

URL: https://gcc.gnu.org/viewcvs?rev=276972&root=gcc&view=rev
Log:
2019-10-14  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92004
	* array.c (expand_constructor): Set from_constructor on
	expression.
	* gfortran.h (gfc_symbol): Add maybe_array.
	(gfc_expr): Add from_constructor.
	* interface.c (maybe_dummy_array_arg): New function.
	(compare_parameter): If the formal argument is generated from a
	call, check the conditions where an array element could be
	passed to an array.  Adjust error message for assumed-shape
	or pointer array.  Use correct language for assumed shaped arrays.
	(gfc_get_formal_from_actual_arglist): Set maybe_array on the
	symbol if the actual argument is an array element fulfilling
	the conditions of 15.5.2.4.

2019-10-14  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92004
	* gfortran.dg/argument_checking_24.f90: New test.
	* gfortran.dg/abstract_type_6.f90: Add error message.
	* gfortran.dg/argument_checking_11.f90: Correct wording
	in error message.
	* gfortran.dg/argumeent_checking_13.f90: Likewise.
	* gfortran.dg/interface_40.f90: Add error message.


Added:
    trunk/gcc/testsuite/gfortran.dg/argument_checking_24.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/array.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/abstract_type_6.f03
    trunk/gcc/testsuite/gfortran.dg/argument_checking_11.f90
    trunk/gcc/testsuite/gfortran.dg/argument_checking_13.f90
    trunk/gcc/testsuite/gfortran.dg/interface_40.f90
Comment 2 Thomas Koenig 2019-10-14 21:39:38 UTC
Fixed, closing.