From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 2D0CE385C017; Fri, 13 Oct 2023 20:08:03 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D0CE385C017 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=127.0.0.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697227683; cv=none; b=HqSQBFX8f/EYqaig4BAE06mGWPMlF4ndaM93CVVXKnWMiltBTemslsGAJ4GmKw3JwBvjGtVWO+MzeJrNen4yuczfSze79mw1Y5R0uy83LESyEY005ggoxcOPRTU/NxXU/jkkENTnHKIMfbnd5lklPpcgqvroQ48ExcGLL0uq4ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697227683; c=relaxed/simple; bh=QqrwjGcxfIYuF39sc5rZCQhRKI8jy1WFymGkvkHNeOo=; h=DKIM-Signature:MIME-Version:From:To:Subject:Message-Id:Date; b=iTSlXFDktwZ+HBmIhQSgoaqN9AWOnS+Vu1nf/SO0Fk8BjK6S48jthubLcK2auAFWpR6w3c0cWhKnpCJXg9DXe9CiXReb3p02lp5I2clJINn0VJRa62JUeR4Lvc70RRcv6t60uINss2YSgwZl9e6KhsFikE5BzBLevKupfdDPO7M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D0CE385C017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697227683; bh=kHyMq2yaiuVv8Lvg46odYOewZDCLqB7AQaeEjefUveU=; h=From:To:Subject:Date:From; b=OqUTyiXLc3wnuJdS/mUh7ey2ftTVXqS7IVf2Hh4amssKvh1Inh3jHnY2/00I+6CtF nz4nLXB7tUGhFjIx8Bftc+LIheFKDzFVKKxxlaL0HW/o4vVzC1z5BKk4/rGKwtQfSc boByfOQaPkhVet1XtuKoQHn6QxeeBVZHzpVY1tDQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4632] Fortran: name conflict between internal procedure and derived type [PR104351] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/master X-Git-Oldrev: 458c253ccdae9df439b9a452d04e325101e5756e X-Git-Newrev: d78fef5371759849944966dec65d9e987efba509 Message-Id: <20231013200803.2D0CE385C017@sourceware.org> Date: Fri, 13 Oct 2023 20:08:03 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d78fef5371759849944966dec65d9e987efba509 commit r14-4632-gd78fef5371759849944966dec65d9e987efba509 Author: Harald Anlauf Date: Wed Oct 11 21:29:35 2023 +0200 Fortran: name conflict between internal procedure and derived type [PR104351] gcc/fortran/ChangeLog: PR fortran/104351 * decl.cc (get_proc_name): Extend name conflict detection between internal procedure and previous declaration also to derived type. gcc/testsuite/ChangeLog: PR fortran/104351 * gfortran.dg/derived_function_interface_1.f90: Adjust pattern. * gfortran.dg/pr104351.f90: New test. Diff: --- gcc/fortran/decl.cc | 4 +++- gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 | 2 +- gcc/testsuite/gfortran.dg/pr104351.f90 | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 4a3c5b86de0..bdd3be32a46 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -1404,7 +1404,9 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) /* Trap declarations of attributes in encompassing scope. The signature for this is that ts.kind is nonzero for no-CLASS entity. For a CLASS entity, ts.kind is zero. */ - if ((sym->ts.kind != 0 || sym->ts.type == BT_CLASS) + if ((sym->ts.kind != 0 + || sym->ts.type == BT_CLASS + || sym->ts.type == BT_DERIVED) && !sym->attr.implicit_type && sym->attr.proc == 0 && gfc_current_ns->parent != NULL diff --git a/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 b/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 index 24a00950912..5438ad49c6a 100644 --- a/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 +++ b/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 @@ -38,7 +38,7 @@ end function ext_fun contains - type(foo) function fun() ! { dg-error "already has an explicit interface" } + type(foo) function fun() ! { dg-error "has an explicit interface" } end function fun ! { dg-error "Expecting END PROGRAM" } end diff --git a/gcc/testsuite/gfortran.dg/pr104351.f90 b/gcc/testsuite/gfortran.dg/pr104351.f90 new file mode 100644 index 00000000000..86b47e03340 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104351.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/104351 +! Contributed by G.Steinmetz + +program p + implicit none + type t + end type + type(t) :: f +contains + real function f() result(z) ! { dg-error "has an explicit interface" } + z = 0.0 ! { dg-error "assignment" } + end function f ! { dg-error "Expecting END PROGRAM" } +end