public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR38065 Fix checking of contained function
@ 2008-11-11 15:24 Tobias Burnus
  2008-11-12  4:31 ` Jerry DeLisle
  2008-11-12 15:27 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 5+ messages in thread
From: Tobias Burnus @ 2008-11-11 15:24 UTC (permalink / raw)
  To: gcc-patches, 'fortran@gcc.gnu.org'

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

gfortran had two bugs:

a) A function, contained in a public module procedure, which returns a
private derived type, was rejected claiming that the function is public,
which is nonsense

b) A public module function, returning a private derived type was
rejected with -std=f2003, but they are only invalid in -std=f95.

The patch fixes both problems and should be save for the regression only
phase as it is simple and prints an error less often than before, which
makes it safe.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias

[-- Attachment #2: privatetype.diff --]
[-- Type: text/plain, Size: 2582 bytes --]

2008-11-11  Tobias Burnus  <burnus@net-b.de>

	PR fortran/38065
	* resolve.c (resolve_fntype): Fix private derived type checking.

2008-11-11  Tobias Burnus  <burnus@net-b.de>

	PR fortran/38065
	* gfortran.dg/private_type_11.f90: New test.
	* gfortran.dg/private_type_12.f90: New test.

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 141763)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -10179,12 +10179,14 @@ resolve_fntype (gfc_namespace *ns)
     }
 
   if (sym->ts.type == BT_DERIVED && !sym->ts.derived->attr.use_assoc
+      && !sym->attr.contained
       && !gfc_check_access (sym->ts.derived->attr.access,
 			    sym->ts.derived->ns->default_access)
       && gfc_check_access (sym->attr.access, sym->ns->default_access))
     {
-      gfc_error ("PUBLIC function '%s' at %L cannot be of PRIVATE type '%s'",
-		 sym->name, &sym->declared_at, sym->ts.derived->name);
+      gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PUBLIC function '%s' at "
+		      "%L of PRIVATE type '%s'", sym->name,
+		      &sym->declared_at, sym->ts.derived->name);
     }
 
     if (ns->entries)
Index: gcc/testsuite/gfortran.dg/private_type_11.f90
===================================================================
--- gcc/testsuite/gfortran.dg/private_type_11.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/private_type_11.f90	(Revision 0)
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+! PR fortran/38065
+!
+! Reported by Norman S. Clerman
+! and reduced by Joost VandeVondele
+!
+MODULE M1
+  IMPLICIT NONE
+  PRIVATE
+  TYPE T1
+   INTEGER :: I1
+  END TYPE T1
+  PUBLIC :: S1,F2
+CONTAINS
+  SUBROUTINE S1
+  CONTAINS
+   TYPE(T1) FUNCTION F1()
+   END FUNCTION F1
+  END SUBROUTINE S1
+  TYPE(T1) FUNCTION F2()
+  END FUNCTION F2
+END MODULE M1
Index: gcc/testsuite/gfortran.dg/private_type_12.f90
===================================================================
--- gcc/testsuite/gfortran.dg/private_type_12.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/private_type_12.f90	(Revision 0)
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+! PR fortran/38065
+!
+! Reported by Norman S. Clerman
+! and reduced by Joost VandeVondele
+!
+MODULE M1
+  IMPLICIT NONE
+  PRIVATE
+  TYPE T1
+   INTEGER :: I1
+  END TYPE T1
+  PUBLIC :: S1,F2
+CONTAINS
+  SUBROUTINE S1
+  CONTAINS
+   TYPE(T1) FUNCTION F1()
+   END FUNCTION F1
+  END SUBROUTINE S1
+  TYPE(T1) FUNCTION F2() ! { dg-error "Fortran 2003: PUBLIC variable 'f2'" }
+  END FUNCTION F2
+END MODULE M1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, Fortran] PR38065 Fix checking of contained function
  2008-11-11 15:24 [Patch, Fortran] PR38065 Fix checking of contained function Tobias Burnus
@ 2008-11-12  4:31 ` Jerry DeLisle
  2008-11-12 15:27 ` Hans-Peter Nilsson
  1 sibling, 0 replies; 5+ messages in thread
From: Jerry DeLisle @ 2008-11-12  4:31 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, 'fortran@gcc.gnu.org'

Tobias Burnus wrote:
> gfortran had two bugs:
> 
> a) A function, contained in a public module procedure, which returns a
> private derived type, was rejected claiming that the function is public,
> which is nonsense
> 
> b) A public module function, returning a private derived type was
> rejected with -std=f2003, but they are only invalid in -std=f95.
> 
> The patch fixes both problems and should be save for the regression only
> phase as it is simple and prints an error less often than before, which
> makes it safe.
> 
> Build and regtested on x86-64-linux.
> OK for the trunk?
> 
> Tobias
> 
OK, Thanks for patch.

Jerry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, Fortran] PR38065 Fix checking of contained function
  2008-11-11 15:24 [Patch, Fortran] PR38065 Fix checking of contained function Tobias Burnus
  2008-11-12  4:31 ` Jerry DeLisle
@ 2008-11-12 15:27 ` Hans-Peter Nilsson
  2008-11-12 15:43   ` H.J. Lu
  2008-11-12 19:03   ` Tobias Burnus
  1 sibling, 2 replies; 5+ messages in thread
From: Hans-Peter Nilsson @ 2008-11-12 15:27 UTC (permalink / raw)
  To: burnus; +Cc: gcc-patches, fortran

(I don't see it reported anywhere, ignore if duplicate.)

> Date: Tue, 11 Nov 2008 16:09:44 +0100
> From: Tobias Burnus <burnus@net-b.de>

> 2008-11-11  Tobias Burnus  <burnus@net-b.de>
> 
> 	PR fortran/38065
> 	* resolve.c (resolve_fntype): Fix private derived type checking.

It looks like your patch caused a regression on all targets, see
also gcc-testresults:

FAIL: gfortran.dg/private_type_4.f90  -O   (test for errors, line 14)

For my autotester for cris-axis-elf, revision 141775 worked,
while it fails since at least 141781.

brgds, H-P

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, Fortran] PR38065 Fix checking of contained function
  2008-11-12 15:27 ` Hans-Peter Nilsson
@ 2008-11-12 15:43   ` H.J. Lu
  2008-11-12 19:03   ` Tobias Burnus
  1 sibling, 0 replies; 5+ messages in thread
From: H.J. Lu @ 2008-11-12 15:43 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: burnus, gcc-patches, fortran

On Wed, Nov 12, 2008 at 7:19 AM, Hans-Peter Nilsson
<hans-peter.nilsson@axis.com> wrote:
> (I don't see it reported anywhere, ignore if duplicate.)
>
>> Date: Tue, 11 Nov 2008 16:09:44 +0100
>> From: Tobias Burnus <burnus@net-b.de>
>
>> 2008-11-11  Tobias Burnus  <burnus@net-b.de>
>>
>>       PR fortran/38065
>>       * resolve.c (resolve_fntype): Fix private derived type checking.
>
> It looks like your patch caused a regression on all targets, see
> also gcc-testresults:
>
> FAIL: gfortran.dg/private_type_4.f90  -O   (test for errors, line 14)
>
> For my autotester for cris-axis-elf, revision 141775 worked,
> while it fails since at least 141781.
>

Yes, this caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38094

-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, Fortran] PR38065 Fix checking of contained function
  2008-11-12 15:27 ` Hans-Peter Nilsson
  2008-11-12 15:43   ` H.J. Lu
@ 2008-11-12 19:03   ` Tobias Burnus
  1 sibling, 0 replies; 5+ messages in thread
From: Tobias Burnus @ 2008-11-12 19:03 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gcc-patches, fortran

Hans-Peter Nilsson wrote:
>> 2008-11-11  Tobias Burnus  <burnus@net-b.de>
>>
>> 	PR fortran/38065
>> 	* resolve.c (resolve_fntype): Fix private derived type checking.
>>     
> It looks like your patch caused a regression on all targets, see
> also gcc-testresults:
>
> FAIL: gfortran.dg/private_type_4.f90  -O   (test for errors, line 14)
>   
Indeed. I wonder why I did not see it with:

   make -j2 check-gfortran//unix/{-m64,-m32}

(One answer could be that I might have misread a part result as final
result.) I have now patched gfortran.dg/private_type_4.f90 and verified
using a simple "make check-gfortran".


The patch itself is OK, the test merely needed a "-std=f95" as the
program is valid in Fortran 2003.
Committed the attached patch as obvious (Rev. 141798).

Thanks for the report.

Tobias

Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (Revision 141797)
+++ testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2008-11-12  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/38065
+       PR fortran/38094
+       * gfortran.dg/private_type_4.f90: Add -std=f95 option.
+
 2008-11-12  Andreas Krebbel  <krebbel1@de.ibm.com>

        * gcc.target/s390/frame-addr1.c: New testcase.
Index: testsuite/gfortran.dg/private_type_4.f90
===================================================================
--- testsuite/gfortran.dg/private_type_4.f90    (Revision 141797)
+++ testsuite/gfortran.dg/private_type_4.f90    (Arbeitskopie)
@@ -1,5 +1,8 @@
 ! { dg-do compile }
+! { dg-options "-std=f95" }
 ! PR 25093: Check that a PUBLIC function can't be of PRIVATE type
+! in Fortran 95; in Fortran 2003 it is allowed (cf. PR fortran/38065)
+!
 module m1

     type :: t1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-12 18:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-11 15:24 [Patch, Fortran] PR38065 Fix checking of contained function Tobias Burnus
2008-11-12  4:31 ` Jerry DeLisle
2008-11-12 15:27 ` Hans-Peter Nilsson
2008-11-12 15:43   ` H.J. Lu
2008-11-12 19:03   ` Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).