This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran,patch] Assign, assigned goto available.


On Tuesday 09 December 2003 09:49, Feng Wang wrote:
> Hi, all
>   This patch implements the assign and related statemnets.

Cool.

> I create two
> variables. One holds the address of target label or the address of format
> string. The other holds the length of format sting and is also used as flag
> to distinguish the two kinds of label . Their decls are both putted into
> lang_decl.

<grin> That's almost the same as what I was doing :-)


>    Now the patch treats "goto label, (100,200,300)" as "goto label". I will
> implement this later.

I'm not so happy with this.  What is "later", can't you implement
this just now?


About the patch:

> --- 1112,1118 ----
>   /* Executable statements that fill gfc_code structures.  */
>   typedef enum
>   {
> !   EXEC_NOP = 1, EXEC_ASSIGN, EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, EXEC_GOTO, EXEC_CALL,
>     EXEC_RETURN, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE,
>     EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_WHILE, EXEC_SELECT,
>     EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT,

Please break up lines >80 columns.


>     if (e->ts.type != tag->type)
>       {
> !       /*Format string can be integer array!!!*/
> !       if (tag != &tag_format)
> !         {
> !           gfc_error ("%s tag at %L must be of type %s", tag->name, >&e->where,
> !           gfc_basic_typename (tag->type));
> !           return FAILURE;
> !         }
>       }

Not GNU style comment.


> +       case EXEC_LABEL_ASSIGN:
> +         if (t == SUCCESS && code->expr->ts.type != BT_INTEGER)
> +           gfc_error ("ASSIGN statement at %L requires an INTEGER "
> +                      "variable", &code->expr->where);
> +         break;

Where are you checking to see if the assigned number is an existing
label?


> +   if (sym->attr.assign)
> +     {
> +       gfc_allocate_lang_decl (decl);
> +       GFC_DECL_ASSIGN (decl) = 1;
> +       GFC_DECL_STRING_LENGTH (decl) = gfc_create_var (gfc_strlen_type_node, sym->name);
> +       GFC_DECL_ASSIGN_ADDR (decl) = gfc_create_var (pvoid_type_node, sym->name);
> +       TREE_STATIC (GFC_DECL_STRING_LENGTH (decl)) = 1;
> +       DECL_INITIAL (GFC_DECL_STRING_LENGTH (decl)) =
> +         build_int_2 (-2, -1);
> +     }

The variable can still also be used as a normal integer variable, so
you should probably not use the same name here.


> +   if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (addr)))
> +       < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (label_tree))))
> +     gfc_error ("The size of variable assigned is too small");

First, we should _never_ have to issue errors in the trans-* files.
We expect a fully resolved and validated Fortran code tree at this
point in the compiler.

Also, from g77 (f/com.c):

/* Transform into ASSIGNable symbol.

   Symbol has already been transformed, but for whatever reason, the
   resulting decl_tree has been deemed not usable for an ASSIGN target.
   (E.g. it isn't wide enough to hold a pointer.)  So, here we invent
   another local symbol of type void * and stuff that in the assign_tree
   argument.  The F77/F90 standards allow this implementation.  */

I believe we should do the same.  In fact I think we should _always_
create another local symbol for ASSIGN.

For now this is not OK.  I'm happy to see you're working on this,
though.  Especially since it takes one item off my own TODO list :-)

Gr.
Steven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]