This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Fwd: GCC 4.3.0 Status Report (2007-08-09)]
- From: "Janus Weil" <jaydub66 at googlemail dot com>
- To: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- Cc: fortran at gcc dot gnu dot org, jaydub66 at gmail dot com, "Steven Bosscher" <stevenb dot gcc at gmail dot com>
- Date: Sat, 11 Aug 2007 19:23:42 +0200
- Subject: Re: [Fwd: GCC 4.3.0 Status Report (2007-08-09)]
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=X0Ict1uqkn47oAkwOOidNP0/kF1ujgdTLLo+xqLcENUKm2+M85z4XCydV9CChQvKp3YfX7i0gL6JFuSRrBbOwWuUv5ya1lmvL3PnPJ801ic0DlyPDQ9vk9I8dAbly6AmfpS3BaC0/PpuIzOhC43f5+1jbl/B6idKIoUvO7e1Zz0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=YXRJFugEnXveybcXdLsOku47iBKgnY15FJYFEJgoO0WGe44kHuRi9+XtZHJu+bfwFBGoCx78dchdAu0G3EPn4EOHTF+R0cLBKebNWpkw3hhqDt/emsS7pHlq3pSMQ2jMgIr5JMx4e/DXIkmKFjnDRvSGpUwLcg1wjTUTu5pTjRk=
- References: <46BBBF88.8030602@codesourcery.com> <19c433eb0708100418u729b337co6ff1ff6071d1f7f7@mail.gmail.com>
Hi all,
since this patch on the PROCEDURE machinery that I'm working on is
quite a big one, I'd propose to split it up into smaller chunks and
commit them separately. It could easily be divided into three parts:
* ABSTRACT interfaces
* simple PROCEDURE declarations
* PROCEDURE pointers
The first and easiest part is the implementation of abstract
interfaces. They aren't very useful without the PROCEDURE syntax, but
they are independent and can be separated from the rest of the stuff
quite easily. I've already put together a patch with the
implementation of abstract interfaces and attached it to this email.
I'd say it's pretty complete and could be committed very soon. It's
basically Paul Thomas' work, I made almost no changes to it.
The second part is about PROCEDURE declarations, which would include
most of the PROCEDURE syntax, but without pointers. This is not yet
complete, but quite advanced. I have a number of working examples, and
just need to implement some more checking and a few other details. I
think this could also be finished until the end of August (hopefully).
The third part completes the PROCEDURE syntax by adding pointers. This
is not really working yet, and I can't guarantee you that it will be
finished until stage 2 closes. If things go well it could make it into
4.3, if not it would have to wait until 4.4. But then we would have
the basic PROCEDURE stuff in 4.3 at least.
So, what do you think of this plan? Do you think it makes sense?
If yes, people could already start reviewing the first patch, and I'd
soon send more details on part two.
Cheers,
Janus
2007/8/10, François-Xavier Coudert <fxcoudert@gmail.com>:
> ** The "procedure pointers and type-bound procedures" by Janus Weil. **
>
> Janus, I now we pinged you recently, but I guess we now really need to
> move forward quickly. IIUC, your SoC patches need to be reviewed and
> approved before entering stage 3. Since you have posted only few
> patches in the past, we can expect a bit of going back and forth
> before final approval (this is not a comment on the quality of your
> patches in any way; just that there always is some adaptation required
> for the first patches, there are so many requirements for inclusion!).
> Thus, it is probably good that you start preparing your current
> patches for formal review (testcases, ChangeLog entries, formatting,
> explanation, etc.) while finishing your work on the procedure pointers
> themselves. In any case, we probably will need patches before the end
> of August.
>
> Of course, this is only my own opinion, and I don't know how much you
> have been in touch with other gfortran maintainers and Steven
> Bosscher. Maybe there's been a lot more going on that what I've seen.
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 127358)
+++ gcc/fortran/interface.c (working copy)
@@ -175,7 +175,8 @@ syntax:
}
-/* Match one of the five forms of an interface statement. */
+/* Match one of the five F95 forms of an interface statement. The
+ matcher for the abstract interface follows. */
match
gfc_match_interface (void)
@@ -232,6 +233,7 @@ gfc_match_interface (void)
break;
case INTERFACE_NAMELESS:
+ case INTERFACE_ABSTRACT:
break;
}
@@ -239,6 +241,33 @@ gfc_match_interface (void)
}
+
+/* Match a F2003 abstract interface. */
+
+match
+gfc_match_abstract_interface (void)
+{
+ match m;
+
+ if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: ABSTRACT INTERFACE at %C")
+ == FAILURE)
+ return MATCH_ERROR;
+
+ m = gfc_match_eos ();
+
+ if (m != MATCH_YES)
+ {
+ gfc_error ("Syntax error: Garbage in ABSTRACT INTERFACE statement "
+ "at %C");
+ return MATCH_ERROR;
+ }
+
+ current_interface.type = INTERFACE_ABSTRACT;
+
+ return m;
+}
+
+
/* Match the different sort of generic-specs that can be present after
the END INTERFACE itself. */
@@ -270,7 +299,8 @@ gfc_match_end_interface (void)
switch (current_interface.type)
{
case INTERFACE_NAMELESS:
- if (type != current_interface.type)
+ case INTERFACE_ABSTRACT:
+ if (type != INTERFACE_NAMELESS)
{
gfc_error ("Expected a nameless interface at %C");
m = MATCH_ERROR;
@@ -2449,6 +2479,7 @@ gfc_add_interface (gfc_symbol *new)
switch (current_interface.type)
{
case INTERFACE_NAMELESS:
+ case INTERFACE_ABSTRACT:
return SUCCESS;
case INTERFACE_INTRINSIC_OP:
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 127358)
+++ gcc/fortran/decl.c (working copy)
@@ -4835,6 +4835,7 @@ access_attr_decl (gfc_statement st)
switch (type)
{
case INTERFACE_NAMELESS:
+ case INTERFACE_ABSTRACT:
goto syntax;
case INTERFACE_GENERIC:
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h (revision 127358)
+++ gcc/fortran/gfortran.h (working copy)
@@ -260,7 +260,7 @@ gfc_statement;
typedef enum
{
INTERFACE_NAMELESS = 1, INTERFACE_GENERIC,
- INTERFACE_INTRINSIC_OP, INTERFACE_USER_OP
+ INTERFACE_INTRINSIC_OP, INTERFACE_USER_OP, INTERFACE_ABSTRACT
}
interface_type;
@@ -657,7 +657,7 @@ typedef struct
/* Function/subroutine attributes */
unsigned sequence:1, elemental:1, pure:1, recursive:1;
- unsigned unmaskable:1, masked:1, contained:1, mod_proc:1;
+ unsigned unmaskable:1, masked:1, contained:1, mod_proc:1, abstract:1;
/* This is set if the subroutine doesn't return. Currently, this
is only possible for intrinsic subroutines. */
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (revision 127358)
+++ gcc/fortran/module.c (working copy)
@@ -599,6 +599,7 @@ gfc_match_use (void)
switch (type)
{
case INTERFACE_NAMELESS:
+ case INTERFACE_ABSTRACT:
gfc_error ("Missing generic specification in USE statement at %C");
goto cleanup;
@@ -1512,7 +1513,7 @@ typedef enum
AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT,
AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP,
AB_POINTER_COMP, AB_PRIVATE_COMP, AB_VALUE, AB_VOLATILE, AB_PROTECTED,
- AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C
+ AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C, AB_ABSTRACT
}
ab_attribute;
@@ -1550,6 +1551,7 @@ static const mstring attr_bits[] =
minit ("POINTER_COMP", AB_POINTER_COMP),
minit ("PRIVATE_COMP", AB_PRIVATE_COMP),
minit ("PROTECTED", AB_PROTECTED),
+ minit ("ABSTRACT", AB_ABSTRACT),
minit (NULL, -1)
};
@@ -1632,6 +1634,8 @@ mio_symbol_attribute (symbol_attribute *
MIO_NAME (ab_attribute) (AB_SUBROUTINE, attr_bits);
if (attr->generic)
MIO_NAME (ab_attribute) (AB_GENERIC, attr_bits);
+ if (attr->abstract)
+ MIO_NAME (ab_attribute) (AB_ABSTRACT, attr_bits);
if (attr->sequence)
MIO_NAME (ab_attribute) (AB_SEQUENCE, attr_bits);
@@ -1732,6 +1736,9 @@ mio_symbol_attribute (symbol_attribute *
case AB_GENERIC:
attr->generic = 1;
break;
+ case AB_ABSTRACT:
+ attr->abstract = 1;
+ break;
case AB_SEQUENCE:
attr->sequence = 1;
break;
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 127358)
+++ gcc/fortran/resolve.c (working copy)
@@ -1968,6 +1968,13 @@ resolve_function (gfc_expr *expr)
return FAILURE;
}
+ if (sym && sym->attr.abstract)
+ {
+ gfc_error ("ABSTRACT INTERFACE '%s' must not be referenced at %L",
+ sym->name, &expr->where);
+ return FAILURE;
+ }
+
/* If the procedure is external, check for usage. */
if (sym && is_external_proc (sym))
resolve_global_procedure (sym, &expr->where, 0);
Index: gcc/fortran/match.h
===================================================================
--- gcc/fortran/match.h (revision 127358)
+++ gcc/fortran/match.h (working copy)
@@ -195,6 +195,7 @@ match gfc_match_array_ref (gfc_array_ref
match gfc_match_array_constructor (gfc_expr **);
/* interface.c. */
+match gfc_match_abstract_interface (void);
match gfc_match_generic_spec (interface_type *, char *, gfc_intrinsic_op *);
match gfc_match_interface (void);
match gfc_match_end_interface (void);
Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c (revision 127358)
+++ gcc/fortran/parse.c (working copy)
@@ -172,6 +172,7 @@ decode_statement (void)
switch (c)
{
case 'a':
+ match ("abstract interface", gfc_match_abstract_interface, ST_INTERFACE);
match ("allocate", gfc_match_allocate, ST_ALLOCATE);
match ("allocatable", gfc_match_allocatable, ST_ATTR_DECL);
match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT);
@@ -1795,6 +1796,9 @@ loop:
}
}
+ if (current_interface.type == INTERFACE_ABSTRACT)
+ gfc_new_block->attr.abstract = 1;
+
push_state (&s2, new_state, gfc_new_block);
accept_statement (st);
prog_unit = gfc_new_block;