* [Patch, Fortran] PR51056 - fix __vtab USE warnings
@ 2012-01-20 7:09 Tobias Burnus
2012-01-20 7:41 ` Paul Richard Thomas
0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-01-20 7:09 UTC (permalink / raw)
To: gcc patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
-Wall was warning about explicitly imported but not used __vtab,
__def_init etc. variables.
Build and regtested on x86-64-linux
OK for the trunk?
Tobias
[-- Attachment #2: module-vtab.diff --]
[-- Type: text/x-patch, Size: 2663 bytes --]
2012-01-20 Tobias Burnus <burnus@net-b.de>
Janus Weil <janus@gcc.gnu.org>
PR fortran/51056
* module.c (load_needed, read_module): Don't mark __vtab etc.
as use_only.
2012-01-20 Tobias Burnus <burnus@net-b.de>
Janus Weil <janus@gcc.gnu.org>
PR fortran/51056
* gfortran.dg/use_21.f90: New.
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 0616a85..b2808d4 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -4351,7 +4351,11 @@ load_needed (pointer_info *p)
mio_symbol (sym);
sym->attr.use_assoc = 1;
- if (only_flag)
+
+ /* Mark as only or rename for later diagnosis for explicitly imported
+ but not used warnings; don't mark internal symbols such as __vtab,
+ __def_init etc. */
+ if (only_flag && sym->name[0] != '_' && sym->name[1] != '_')
sym->attr.use_only = 1;
if (p->u.rsym.renamed)
sym->attr.use_rename = 1;
@@ -4574,8 +4578,9 @@ read_module (void)
p = name;
/* Exception: Always import vtabs & vtypes. */
- if (p == NULL && (strncmp (name, "__vtab_", 5) == 0
- || strncmp (name, "__vtype_", 6) == 0))
+ if (p == NULL && name[0] == '_'
+ && (strncmp (name, "__vtab_", 5) == 0
+ || strncmp (name, "__vtype_", 6) == 0))
p = name;
/* Skip symtree nodes not in an ONLY clause, unless there
@@ -4641,7 +4646,10 @@ read_module (void)
if (strcmp (name, p) != 0)
sym->attr.use_rename = 1;
- sym->attr.use_only = only_flag;
+ if (name[0] != '_'
+ || (strncmp (name, "__vtab_", 5) != 0
+ && strncmp (name, "__vtype_", 6) != 0))
+ sym->attr.use_only = only_flag;
/* Store the symtree pointing to this symbol. */
info->u.rsym.symtree = st;
--- /dev/null 2012-01-19 08:39:17.883655782 +0100
+++ gcc/gcc/testsuite/gfortran.dg/use_21.f90 2012-01-19 20:12:11.000000000 +0100
@@ -0,0 +1,35 @@
+! { dg-do compile }
+! { dg-options "-Wall" }
+!
+! PR fortran/51056
+!
+! Contributed by Kacper Kowalik
+!
+module domain
+ implicit none
+ private
+ public :: domain_container, dom
+
+ type :: domain_container
+ integer :: D_x !< set to 1 when x-direction exists, 0 otherwise
+ contains
+ procedure :: init => init_domain_container
+ end type domain_container
+
+ type(domain_container) :: dom
+
+ contains
+ subroutine init_domain_container(this)
+ implicit none
+ class(domain_container), intent(inout) :: this
+ this%D_x = 0
+ end subroutine init_domain_container
+end module domain
+
+program ala
+ use domain, only: dom
+ implicit none
+ call dom%init
+end program ala
+
+! { dg-final { cleanup-modules "domain" } }
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch, Fortran] PR51056 - fix __vtab USE warnings
2012-01-20 7:09 [Patch, Fortran] PR51056 - fix __vtab USE warnings Tobias Burnus
@ 2012-01-20 7:41 ` Paul Richard Thomas
0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2012-01-20 7:41 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc patches, gfortran
Dear Tobias,
This patch is OK for trunk.
I have made a lot of progress on PR51870; class scalars work correctly
but I need to extend the fix to class arrays. It requires a complete
rewrite of the parts of gfc_trans_allocate that are associated with
class allocation and initialization. The result is much cleaner and
is based on the API in trans-expr.c, rather than the present kludgy
use of the frontend.
Cheers
Paul
On Fri, Jan 20, 2012 at 8:09 AM, Tobias Burnus <burnus@net-b.de> wrote:
> -Wall was warning about explicitly imported but not used __vtab, __def_init
> etc. variables.
>
> Build and regtested on x86-64-linux
> OK for the trunk?
>
> Tobias
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-20 7:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20 7:09 [Patch, Fortran] PR51056 - fix __vtab USE warnings Tobias Burnus
2012-01-20 7:41 ` Paul Richard Thomas
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).