patch(es) to date for fortran-experiments

Bernhard Fischer rep.dot.nop@gmail.com
Sat Jan 13 17:37:00 GMT 2007


On Fri, Jan 12, 2007 at 10:43:09PM -0700, Christopher D. Rickett wrote:
>hi all,
>
>i attached another patch, which actually contains the previous patches
>i've sent out.  i thought it might be easier to look at the most recent,
>but if it's easier for the reviewer, i can go through the diff and remove
>what i've already submitted.
>
>the basic descriptions:
>- the bugs listed for bind(c) variables on the wiki should now be handled
>correctly.
>- the bug for validating C interoperable kinds (also on the wiki) should
>be fixed.
>- error checking is done to make sure bind(c) variables are only at the
>module-level scope, unless they're common blocks.
>- parsing bug for bind(c) attribute should be fixed.
>- test cases for the fixed bugs.  more test cases to come, once i fix the
>dg-error syntax.
>
>hope the patch helps.  let me know if i need to remove the previous
>patches from this diff.  thanks.

Some cosmetic nitpicks below. I did not look at the actual code.

>
>Chris
>Index: gcc/testsuite/ChangeLog
>===================================================================
>--- gcc/testsuite/ChangeLog	(revision 120745)
>+++ gcc/testsuite/ChangeLog	(working copy)
>@@ -1,3 +1,19 @@
>+2007-01-12  Christopher D. Rickett  <crickett@lanl.gov>
>+	* gfortran.dg/kind_tests_2.f03: New testcase for verifying C
>+	interoperable kinds.
>+	* gfortran.dg/kind_tests_3.f03: New testcase for verifying C
>+	interoperable kinds.
>+	* gfortran.dg/bind_c_usage_2.f03: New testcase for BIND(C)
>+	variables. 
>+
>+2007-01-11  Christopher D. Rickett  <crickett@lanl.gov>
>+	* gfortran.dg/c_ptr_tests.f90: Renamed to c_ptr_test.f03
>+	* gfortran.dg/c_ptr_tests.f03: Changed subroutine name and removed
>+	unnecessary code.
>+	* gfortran.dg/c_ptr_tests_driver.c: Modified to match with
>+	c_ptr_tests.f03. 
>+	* gfortran.dg/dg.exp: Modified to accept .f03/.F03 files.
>+
> 2006-12-20  Roger Sayle  <roger@eyesopen.com>
> 
> 	* gfortran.dg/array_memset_1.f90: New test case.

[snip testcases]

>Index: gcc/fortran/symbol.c
>===================================================================
>--- gcc/fortran/symbol.c	(revision 120745)
>+++ gcc/fortran/symbol.c	(working copy)
>@@ -2897,12 +2897,13 @@ gfc_get_gsymbol (const char *name)
>  *
>  * @param derived_sym <code>#gfc_symbol</code> representing the derived type
>  * to test for C interoperability.
>- * @return None
>+ * @return SUCCESS or FAILURE
>  */
>-void verify_bind_c_derived_type(gfc_symbol *derived_sym)
>+try verify_bind_c_derived_type(gfc_symbol *derived_sym)

Missing space between function name and parm list.

> {
>    gfc_component *curr_comp = NULL;
>    try is_c_interop = FAILURE;
>+  try retval = SUCCESS;
>    
>    if(derived_sym == NULL)
>       gfc_internal_error("verify_bind_c_derived_type(): Given symbol is "
>@@ -2911,8 +2912,11 @@ void verify_bind_c_derived_type(gfc_symb
>    curr_comp = derived_sym->components;
>    /* is this really an error??  --Rickett, 10.24.05 */
>    if(curr_comp == NULL)
>+    {
>       gfc_error("No fields in the derived type %s at %C",

Missing space between function name and parm list.

I would understand "Derived type '%s' at %C is empty" or "has no
members" better.

>                 derived_sym->name);
>+      return FAILURE;
>+    }
> 
>    /* initialize the derived type as being C interoperable.

Sentence should start with a capital letter.

>     * if we find an error in the components, this will be set false
>@@ -2934,6 +2938,7 @@ void verify_bind_c_derived_type(gfc_symb
>                        "the TYPE component '%s' at %L",
>                        derived_sym->name, &(derived_sym->declared_at),
>                        curr_comp->name, &(curr_comp->loc));
>+          retval = FAILURE;
>       }/* end if(type component inside bind(c) derived type) */

s,/.*,,

>       else
>       {
>@@ -2973,42 +2978,58 @@ void verify_bind_c_derived_type(gfc_symb
>             derived_sym->ts.is_c_interop = 0;
>          }/* end if(component isn't C interoperable) */

ditto
> 
>-         /* the components can not be pointers (fortran sense) or
>-          * allocatable.  J3/04-007, Section 15.2.3, C1505
>+          /* The components can not be pointers (fortran sense).
>+           * J3/04-007, Section 15.2.3, C1505
>           */

Should be
/* The components...
   J3/04-007, Section 15.2.3, C1505.  */

i.e. no asterisk for continued lines within a comment block
After a sentence two spaces are required.  Like here.
Don't put the closing "*/" on a different line but on the same line.

>          if(curr_comp->pointer != 0)

missing space after if
>+            {
>             gfc_error_now("Component '%s' at %L can not have the "

Missing space between function name and parm list.

"cannot"
>                           "POINTER attribute because it is a member "
>-                          "of the BIND(C) derived type '%s' at %L",
>+                             "of the BIND(C) derived type '%s' at %C",
>                           curr_comp->name, &(curr_comp->loc),
>-                          derived_sym->name, &(derived_sym->declared_at));
>+                             derived_sym->name);
>+              retval = FAILURE;
>+            }
>+
>+          /* The components can not be allocatable.
>+           * J3/04-007, Section 15.2.3, C1505
>+           */

Remove asterisk from the beginning of lines within a comment block, end
the reference to the std with a ".  */" thus putting the closing comment
in the same line.

>+          if (curr_comp->allocatable != 0)
>+            {
>+              gfc_error ("Component '%s' at %L cannot have the "
>+                         "ALLOCATABLE attribute because it is a member "
>+                         "of the BIND(C) derived type '%s' at %C",
>+                         curr_comp->name, &(curr_comp->loc),
>+                         derived_sym->name);
>+              retval = FAILURE;
>+            }
>       }/* end else(was not a derived type, so checked the kind) */

s,/.*,,

> 
>       curr_comp = curr_comp->next;
>    }while(curr_comp != NULL); /*  && isCInteroperable == SUCCESS); */

missing space after while, remove comment
>    
>+
>    /* make sure we don't have conflicts with the attributes */
>    if(derived_sym->attr.access == ACCESS_PRIVATE)

missing space after if
>+    {
>       gfc_error_now("Derived type %s at %C can not be declared with both "

Perhaps "cannot" like Brooks said.
Also, the space after the function name is missing.

>                     "PRIVATE and BIND(C) attributes", derived_sym->name);
>+      retval = FAILURE;
>+    }
> 
>    /* not sure what other attrs to check for conflicts with bind(c).
>     * need to check the standard.  --Rickett, 10.24.05
>     */
> 
>    if(derived_sym->attr.sequence != 0)
>+    {
>       gfc_error_now("Derived type '%s' at %L can not have the SEQUENCE "

ditto (and comment block above is non-standard)

>                     "attribute because it is BIND(C)", derived_sym->name,
>                     &(derived_sym->declared_at));

You seem to repeat this warning alot with varying attributes.
Perhaps factor this out like in symbol.c::check_conflict() ?

>+      retval = FAILURE;
>+    }
> 
>-   /* make sure we clear out any buffered errors since we're not
>-    * returning a status to the caller about whether an error
>-    * was encountered or not
>-    */
>-/*    gfc_warning_check(); */
>-/*    gfc_error_check(); */
>-   
>-   return;
>+  return retval;
> }/* end verify_bind_c_derived_type() */

s,/.*,,

> 
> 
>@@ -3325,14 +3346,17 @@ static void gen_c_interop_ptr_syms(const
>             gfc_internal_error("generateCInteropPtrKinds(): Unable to "

Missing space between function name and parms.

>                                "create component for c_address");
>          tmp_comp->ts.type = BT_INTEGER;
>+         /* Set this field because it will be read from and written to
>+          * the module file. */

missing space after the dot since two spaces are required.

>+         tmp_comp->ts.f90_type = BT_INTEGER;
>          /* the kinds for c_ptr and c_funptr are the same. */
>          index = get_c_kind("c_ptr", c_interop_kinds_table);
>          tmp_comp->ts.kind = c_interop_kinds_table[index].value;
>+         /* Mark the component as C interoperable. */

Missing space after dot

>+         tmp_comp->ts.is_c_interop = 1;
>          
>          tmp_comp->pointer = 0;
>          tmp_comp->dimension = 0;
>-         /* initialize the value of the c_address field to NULL */
>-         tmp_comp->initializer = gfc_int_expr(0);
> 
>          /* make it use associated (iso_c_binding module) */
>          tmp_sym->attr.use_assoc = 1;
>@@ -3399,12 +3423,8 @@ static void gen_special_c_interop_ptrs(c
>                                "create symbol for %s", kinds[i]);
>          }
> 
>-         /* set up the symbol's important fields. */
>-         /* FIXME: this is causing the compiler to ICE with a seg'v..
>-          * --Rickett, 09.15.06
>-          */
>-/*          tmp_sym->attr.flavor = FL_PARAMETER; */
>-         /* save attr required so we can initialize the ptr to NULL */
>+         /* Set up the symbol's important fields. */

missing space at end of sentence
>+         /* Save attr required so we can initialize the ptr to NULL */

missing ".  "
>          tmp_sym->attr.save = 1;
>          tmp_sym->ts.is_c_interop = 1;
>          tmp_sym->attr.is_c_interop = 1;
>@@ -3436,10 +3456,22 @@ static void gen_special_c_interop_ptrs(c
>          sprintf(tmp_sym->binding_label, "%s_%s", module_name,
>                  tmp_sym->name);
> 
>-         /* the c_address field held by the derived types c_ptr
>-          * and c_funptr is initialized to 0 by default when they
>-          * are created.  see gen_c_interop_ptr_syms().
>+	 /* Set the c_address field of c_null_ptr and c_null_funptr to
>+	  * the value of NULL.
>+	  */

Should be "NULL.  */" and without the '*' at the start of the line in a
comment block.
>+	 tmp_sym->value = gfc_get_expr ();
>+	 tmp_sym->value->expr_type = EXPR_STRUCTURE;
>+	 tmp_sym->value->ts.type = BT_DERIVED;
>+	 tmp_sym->value->ts.derived = tmp_sym->ts.derived;
>+	 tmp_sym->value->value.constructor = gfc_get_constructor ();
>+	 /* This line will initialize the c_null_ptr/c_null_funptr
>+	  * c_address field to NULL.
>+	  */

ditto.

>+	 tmp_sym->value->value.constructor->expr = gfc_int_expr (0);
>+	 /* Must declare c_null_ptr and c_null_funptr as having the
>+	  * PARAMETER attribute so they can be used in init expressions.
>           */
ditto.
>+	 tmp_sym->attr.flavor = FL_PARAMETER;
>       }/* end if(symbol hasn't already been created) */
s,/.*,,
> 
>       /* while loop counter */
>@@ -4127,6 +4159,9 @@ generate_isocbinding_symbol (const char 
> 			      "create component for c_address");
> 
>         tmp_comp->ts.type = BT_INTEGER;
>+        /* Set this because the module will need to read/write this
>+         * field. */

No leading asterisk and missing space.

>+        tmp_comp->ts.f90_type = BT_INTEGER;
> 
>         /* the kinds for c_ptr and c_funptr are the same. */

missing space and should start with a capital 'T' in The

>         index = get_c_kind("c_ptr", c_interop_kinds_table);
>@@ -4135,11 +4170,27 @@ generate_isocbinding_symbol (const char 
>         tmp_comp->pointer = 0;
>         tmp_comp->dimension = 0;
> 
>-        /* initialize the value of the c_address field to NULL */
>-        tmp_comp->initializer = gfc_int_expr (0);
>+        /* Mark the component as C interoperable. */

missing space

>+        tmp_comp->ts.is_c_interop = 1;
> 
>         /* make it use associated (iso_c_binding module) */
>         tmp_sym->attr.use_assoc = 1;
>+
>+	/* Need to decide whether to generate the symbols for c_null_ptr
>+	 * or c_null_funptr (i.e., whether c_ptr and c_funptr are defined).
>+	 */

Remove asterisk from line in comment block and put the closing comment
in the same line:
... are defined).  */

>+	if (s == ISOCBINDING_PTR)
>+	  {
>+	    /* c_ptr was created so create c_null_ptr */
>+	    const char *ptr_kinds[2] = {"c_ptr", NULL};
>+	    gen_special_c_interop_ptrs (ptr_kinds, mod_name);
>+	  }
>+	else
>+	  {
>+	    /* c_funptr was created so create c_null_funptr */
>+	    const char *ptr_kinds[2] = {"c_funptr", NULL};
>+	    gen_special_c_interop_ptrs (ptr_kinds, mod_name);
>+	  }/* end if(c_funptr created) */
> 	break;
> 
>       case ISOCBINDING_F_POINTER:
>Index: gcc/fortran/decl.c
>===================================================================
>--- gcc/fortran/decl.c	(revision 120745)
>+++ gcc/fortran/decl.c	(working copy)
>@@ -852,6 +852,8 @@ build_sym (const char *name, gfc_charlen
>    */
>   if(sym->attr.is_bind_c == 1)
>   {
>+    try retval;
>+    
>      if(sym->binding_label[0] == '\0')
>      {
>         /* here, we're not checking the numIdents (the last param)!!!
>@@ -874,7 +876,7 @@ build_sym (const char *name, gfc_charlen
>       * the 0 param means it's not in a common (or not that we care).
>       * the NULL is for the non-existent commonHead
>       */
>-     verify_bind_c_sym(sym, &current_ts, 0, NULL);
>+     retval = verify_bind_c_sym(sym, &current_ts, 0, NULL);
>   }/* end if(symbol is a bind(c) */

s,/.*,,

> 
>   /* see if we know we're in a common block, and if it's a bind(c)
>@@ -1145,6 +1147,8 @@ add_init_expr_to_sym (const char *name, 
>          /* attr bits needed for module files */
>          sym->attr.is_iso_c |= init->ts.is_iso_c;
>          sym->attr.is_c_interop |= init->ts.is_c_interop;
>+	 if (init->ts.is_iso_c)
>+	   sym->ts.f90_type = init->ts.f90_type;
>       }/* end if(not a character or derived type) */
s,/.*,,
>       
>       sym->value = init;
>@@ -1593,6 +1597,43 @@ variable_decl (int elem)
>       t = build_struct (name, cl, &initializer, &as);
>     }
> 
>+  /* If the symbol is bind(c), we need to verify the attributes. */

missing space after dot

>+  if (current_attr.is_bind_c == 1)
>+    {
>+      /* Get the symbol. */

ditto

>+      gfc_find_symbol(name, gfc_current_ns, 1, &sym);
missing space between function name and parm list
>+      if (sym == NULL)
>+	gfc_internal_error("variable_decl(): Missing symbol for '%s'",
>+			   name);
>+
>+      /* First, make sure the variable is declared at the
>+       * module-level scope. (section 15.3)
>+       */

Remove asterisk from line in comment block and put the closing comment
in the same line.

>+      if (sym->ns->proc_name->attr.flavor != FL_MODULE)
>+	{
>+	  gfc_error("Variable '%s' at %C cannot be BIND(C) because it "
>+		    "is neither a COMMON block nor declared at the "
>+		    "module level scope", sym->name);
>+	  t = FAILURE;
>+	}
>+      else
>+	{
>+	  /* If type() declaration, we need to verify that the components
>+	   * of the given type are all C interoperable, etc.
>+	   */

ditto

>+	  if (current_ts.type == BT_DERIVED)
>+	    t = verify_bind_c_derived_type(current_ts.derived);

missing space between function name and parm
>+	  
>+	  /* Now, verify the variable itself as C interoperable, etc. */

missing space after the dot

>+	  if (t == SUCCESS)
>+	  {
>+	    /* Verify that the symbol is C interoperable if it's bind(c). */

ditto

>+	    t = verify_bind_c_sym(sym, &(sym->ts), sym->attr.in_common,

missing space between function name and parm

>+				  sym->common_block);
>+	  }
>+	}
>+    }
>+  
>   m = (t == SUCCESS) ? MATCH_YES : MATCH_ERROR;
> 
> cleanup:
>@@ -2479,8 +2520,17 @@ match_attr_spec (void)
> 
>      if(d == DECL_NONE)
>      {
>-        /* see if we can find the bind(c) since all else failed */ 
>-        if(gfc_peek_char() == ',')
>+       /* See if we can find the bind(c) since all else failed. 
>+	* We need to skip over any whitespace and stop on the ','.
>+	*/
>+/*        do */
>+/* 	 { */
>+/* 	   peek_char = gfc_next_char(); */
>+/* 	 } while (peek_char != ',' && peek_char != '\0'); */

dead code or a reminder / TODO ?

>+
>+       gfc_gobble_whitespace();

missing space between function and parm specifier.

>+       peek_char = gfc_peek_char();

ditto

>+       if (peek_char == ',')
>         {
>            /* chomp the comma */
>            peek_char = gfc_next_char();
>@@ -2878,17 +2928,18 @@ try verify_c_interop(gfc_typespec *ts)
>  * a C interoperable type.  Errors will be reported here, if encountered.
>  *
>  * @param com_block <code>gfc_common_head</code> being tested.
>- * @return None.
>+ * @return SUCCESS or FAILURE.
>  */
>-void verify_com_block_vars_c_interop(gfc_common_head *com_block)
>+try verify_com_block_vars_c_interop(gfc_common_head *com_block)

ditto.

> {
>    gfc_symbol *curr_sym = NULL;
>+  try retval = SUCCESS;
> 
>    curr_sym = com_block->head;
> 
>    /* make sure we have at least one symbol */
>    if(curr_sym == NULL)
>-      return;
>+      return retval;
> 
>    /* here we know we have a symbol, so we'll execute this loop
>     * at least once.
>@@ -2896,11 +2947,11 @@ void verify_com_block_vars_c_interop(gfc
>    do
>    {
>       /* the second to last param, 1, says this is in a common block */
>-      verify_bind_c_sym(curr_sym, &(curr_sym->ts), 1, com_block);
>+      retval = verify_bind_c_sym(curr_sym, &(curr_sym->ts), 1, com_block);

ditto.

>       curr_sym = curr_sym->common_next;
>    }while(curr_sym != NULL); 
> 
>-   return;
>+   return retval;
> }/* end verify_com_block_vars_c_interop() */

s,/.*,,

> 
> 
>@@ -2919,14 +2970,16 @@ void verify_com_block_vars_c_interop(gfc
>  * common block.  1 if it is; 0 if it is not. 
>  * @param com_block The common block that the given symbol belongs to,
>  * if any.
>- * @return None.
>+ * @return SUCCESS/FAULURE
>  */
>-void verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,
>+try verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,

missing space between function and parm specifier.

>                        int is_in_common, gfc_common_head *com_block)
> {
>-   /* don't test variables declared of some derived type */
>-   if(tmp_sym->ts.type == BT_DERIVED || ts->type == BT_DERIVED)
>-      return;
>+  try retval = SUCCESS;
>+  
>+/*    /\* don't test variables declared of some derived type *\/ */
>+/*    if(tmp_sym->ts.type == BT_DERIVED || ts->type == BT_DERIVED) */
>+/*       return SUCCESS; */
>    
>    /* here, we know we have the bind(c) attribute, so if we have
>     * enough type info, then verify that it's a C interop kind
>@@ -2962,16 +3015,37 @@ void verify_bind_c_sym(gfc_symbol *tmp_s
>        */
>       if(is_in_common == 1 && tmp_sym->attr.is_bind_c == 1)
>       {
>-         gfc_error_now("Variable \"%s\" in common block \"%s\" at "
>+         gfc_error ("Variable \"%s\" in common block \"%s\" at "

I think we usually enclose names in '\'', i.e.:
gfc_error ("Variable '%s' in COMMON block '%s' at "

>                        "%L can not be declared with bind(c) "

"cannot" ?

>                        "since it is not a global",
>                        tmp_sym->name, com_block->name,
>                        &(tmp_sym->declared_at));
>+         retval = FAILURE;
>       }/* end if(common block field declared with bind(c)) */

s,/.*,,

>+
>+      /* Scalar variables that are bind(c) can not have the pointer
>+       * or allocatable attributes.
>+       */

Remove asterisk from within comment block and put closing comment on the
same line.

>+      if (tmp_sym->attr.is_bind_c == 1)
>+        {
>+          if (tmp_sym->attr.pointer == 1)
>+            {
>+              gfc_error ("Variable '%s' at %L cannot have both the "
>+                         "POINTER and BIND(C) attributes",
>+                         tmp_sym->name, &(tmp_sym->declared_at));
>+              retval = FAILURE;
>+            }
>+          if (tmp_sym->attr.allocatable == 1)
>+            {
>+              gfc_error ("Variable '%s' at %L cannot have both the "
>+                         "ALLOCATABLE and BIND(C) attributes",
>+                         tmp_sym->name, &(tmp_sym->declared_at));
>+              retval = FAILURE;
>+            }
>+        }
>    }/* end if(type info is known (i.e., variable has been declared)) */

s,/.*,,

> 
>-   /* no flag returned; if there's an error, we've printed it */
>-   return;
>+   return retval;
> }/* end verify_bind_c_sym() */

ditto
> 
> 
>@@ -2993,7 +3067,9 @@ void verify_bind_c_sym(gfc_symbol *tmp_s
> try set_verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,
>                           int num_idents)
> {
>-   /* hmm, do we need to make sure the vars aren't marked private?
>+  try retval = SUCCESS;
>+  
>+   /* Do we need to make sure the vars aren't marked private?
>     * --Rickett, 10.28.05
>     */
> 
>@@ -3002,6 +3078,7 @@ try set_verify_bind_c_sym(gfc_symbol *tm
>    {
>       gfc_error_now("Variable \"%s\" already declared as bind(c) "

Wrong quoting char

>                     "at %L", tmp_sym->name, &(tmp_sym->declared_at));
>+      retval = FAILURE;
>    }/* end if(was already defined as bind(c)) */

s,/.*,,

> 
>    /* set the is_bind_c bit in symbol_attribute */
>@@ -3014,9 +3091,10 @@ try set_verify_bind_c_sym(gfc_symbol *tm
>    /* we'll let this function print errors, so don't worry about
>     * success/fail here and just continue parsing.
>     */
>-   verify_bind_c_sym(tmp_sym, ts, 0, NULL);
>+   retval = verify_bind_c_sym(tmp_sym, ts, 0, NULL);

missing space between function name and parms
>    
>-   return SUCCESS;
>+/*    return SUCCESS; */
>+   return retval;
> }/* end set_verify_bind_c_sym() */

s,/.*,,
> 
> 
>@@ -3033,6 +3111,8 @@ try set_verify_bind_c_sym(gfc_symbol *tm
> try set_verify_bind_c_com_block(gfc_common_head *com_block,
>                                 int num_idents)
> {
>+  try retval = SUCCESS;
>+  
>    /* destLabel, common name, typespec (which may have binding label) */
>    if(set_binding_label(com_block->binding_label, com_block->name, 

missing space after "if"

>                         num_idents) != SUCCESS)
>@@ -3045,9 +3125,9 @@ try set_verify_bind_c_com_block(gfc_comm
>     * don't check for failure or success here, because the function
>     * will handle printing the appropriate error msg(s).
>     */
>-   verify_com_block_vars_c_interop(com_block);
>+   retval = verify_com_block_vars_c_interop(com_block);

missing space between function name and parms

>    
>-   return SUCCESS;
>+   return retval;
> }/* end set_verify_bind_c_com_block() */

s,/.*,,
> 
> 
>Index: gcc/fortran/gfortran.h
>===================================================================
>--- gcc/fortran/gfortran.h	(revision 120745)
>+++ gcc/fortran/gfortran.h	(working copy)
>@@ -1980,7 +1980,7 @@ int gfc_find_symbol (const char *, gfc_n
> int gfc_find_sym_tree (const char *, gfc_namespace *, int, gfc_symtree **);
> int gfc_get_symbol (const char *, gfc_namespace *, gfc_symbol **);
> try verify_c_interop(gfc_typespec *ts);
>-void verify_bind_c_derived_type(gfc_symbol *derived_sym);
>+try verify_bind_c_derived_type(gfc_symbol *derived_sym);

missing space between function name and parms

> void generate_isocbinding_symbol (const char *, iso_c_binding_symbol, char *);
> void gen_c_interop_kinds(const char *mod_name, CInteropKind_t *kinds[]);
> gfc_symbol *get_iso_c_sym(gfc_symbol *old_sym, char *new_name,
>Index: gcc/fortran/module.c
>===================================================================
>--- gcc/fortran/module.c	(revision 120745)
>+++ gcc/fortran/module.c	(working copy)
>@@ -1826,7 +1826,6 @@ check_unique_name (const char *name)
> static void
> mio_typespec (gfc_typespec * ts)
> {
>-
>   mio_lparen ();
> 
>   ts->type = MIO_NAME(bt) (ts->type, bt_types);
>@@ -1840,9 +1839,17 @@ mio_typespec (gfc_typespec * ts)
>   /* in the case of the iso_c_binding named constants, this field
>    * says what fortran types it can work with.
>    */
>-  ts->f90_type = ts->type;
>+/*   ts->f90_type = ts->type; */
>   mio_integer(&ts->is_c_interop);
>   mio_integer(&ts->is_iso_c);
>+  /* If the typespec is for an identifier either from iso_c_binding, or
>+   * a constant that was initialized to an identifier from it, use the
>+   * f90_type.  Otherwise, use the ts->type, since it shouldn't matter. */

Remove asterisks from within comment block and missing second space at
end of comment.

>+  if (ts->is_iso_c)
>+    ts->f90_type = MIO_NAME(bt) (ts->f90_type, bt_types);
>+  else
>+    ts->f90_type = MIO_NAME(bt) (ts->type, bt_types);

missing space between macro name and parms
>+
>   
>   mio_charlen (&ts->cl);
> 
>Index: gcc/fortran/lang-specs.h
>===================================================================
>--- gcc/fortran/lang-specs.h	(revision 120745)
>+++ gcc/fortran/lang-specs.h	(working copy)
>@@ -18,6 +18,7 @@ This file is licensed under the GPL.  */
>       -fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
> {".F90", "@f95-cpp-input", 0, 0, 0},
> {".F95", "@f95-cpp-input", 0, 0, 0},
>+{".F03", "@f95-cpp-input", 0, 0, 0},
> {"@f95-cpp-input",
>   "cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
>       %{E|M|MM:%(cpp_debug_options)}\
>@@ -26,6 +27,7 @@ This file is licensed under the GPL.  */
>       -fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
> {".f90", "@f95", 0, 0, 0},
> {".f95", "@f95", 0, 0, 0},
>+{".f03", "@f95", 0, 0, 0},  
> {"@f95", "%{!E:f951 %i %(cc1_options) %{J*} %{I*}\
>          %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}", 0, 0, 0},
> {".f",   "@f77", 0, 0, 0},
>Index: gcc/fortran/match.h
>===================================================================
>--- gcc/fortran/match.h	(revision 120745)
>+++ gcc/fortran/match.h	(working copy)
>@@ -165,11 +165,11 @@ match gfc_match_volatile (void);
> /* some of these should be moved to another file rather than decl.c */
> /* decl.c */
> void verify_c_interop_param(gfc_symbol *sym);
>-void verify_com_block_vars_c_interop(gfc_common_head *com_block);
>+try verify_com_block_vars_c_interop(gfc_common_head *com_block);
> void set_com_block_bind_c(gfc_common_head *com_block, int is_bind_c);
> try set_binding_label(char *dest_label, const char *sym_name,
>                       int num_idents);
>-void verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,
>+try verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,
>                        int is_in_common, gfc_common_head *com_block);
> try set_verify_bind_c_sym(gfc_symbol *tmp_sym, gfc_typespec *ts,
>                           int num_idents);

missing space between function name and parms in all them

>Index: gcc/fortran/options.c
>===================================================================
>--- gcc/fortran/options.c	(revision 120745)
>+++ gcc/fortran/options.c	(working copy)
>@@ -137,6 +137,9 @@ form_from_filename (const char *filename
>     ".f95", FORM_FREE}
>     ,
>     {
>+    ".f03", FORM_FREE}
>+    ,
>+    {
>     ".f", FORM_FIXED}
>     ,
>     {
>Index: gcc/fortran/ChangeLog.isocbinding
>===================================================================
>--- gcc/fortran/ChangeLog.isocbinding	(revision 120745)
>+++ gcc/fortran/ChangeLog.isocbinding	(working copy)
>@@ -3,6 +3,32 @@ Welcome to the ISO_C_BINDING sandbox!
> Please comment here the changes you make to the code, dated with every
> commit to the branch, so that we don't get lost.
> 
>+2007-01-12  Christopher D. Rickett
>+	* gcc/fortran/symbol.c: Fixed bugs in c_null_ptr/c_null_funptr.
>+	Changed the way errors were handled for checking BIND(C)
>+	variables. 
>+	* gcc/fortran/decl.c: Fixed bugs in verifying BIND(C) variables
>+	and C interoperable kinds.  Modified the way errors for each are
>+	handled in some cases.
>+	* gcc/fortran/gfortran.h: Changed the return type of
>+	verify_bind_c_derived_type(). 
>+	* gcc/fortran/module.c: Added the ts.f90_type field to the module
>+	file. 
>+	* gcc/fortran/match.h: Changed the return types of
>+	verify_com_block_vars_c_interop() and verify_bind_c_sym().
>+	* libgfortran/intrinsics/iso_c_binding.h: Removed the declarations
>+	of c_null_ptr and c_null_funptr.
>+
>+
>+2007-01-11  Christopher D. Rickett
>+
>+	* gcc/fortran/symbol.c: (generate_isocbinding_symbol): Added
>+	  function calls for generating c_null_ptr and c_null_funptr.
>+	* gcc/fortran/lang-specs.h: Added options for .f03/.F03 file
>+	  extensions. 
>+	* gcc/fortran/options.c: (form_from_filename): Added entry for
>+	  .f03/.F03 file extensions.
>+
> 2006-12-27  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	* Revert revision 120187, 120190, and 120209.
>Index: libgfortran/intrinsics/iso_c_binding.h
>===================================================================
>--- libgfortran/intrinsics/iso_c_binding.h	(revision 120745)
>+++ libgfortran/intrinsics/iso_c_binding.h	(working copy)
>@@ -15,17 +15,18 @@ typedef struct c_funptr
> 
> #define ISO_C_BINDING_PREFIX(a) __iso_c_binding_##a
> 
>-
>-/* define variables for c_null_ptr and c_null_funptr.  found at
>- * link time.
>+/* These definitions for c_null_ptr and c_null_funptr should no
>+ * longer be needed because the Fortran frontend creates compile
>+ * time constants for them with the value for NULL in c_address.
>  */
>-c_ptr_t ISO_C_BINDING_PREFIX(c_null_ptr);
>-c_funptr_t ISO_C_BINDING_PREFIX(c_null_funptr);
>+/* c_ptr_t ISO_C_BINDING_PREFIX(c_null_ptr); */
>+/* c_funptr_t ISO_C_BINDING_PREFIX(c_null_funptr); */

dead code?
> 
> void ISO_C_BINDING_PREFIX(c_f_pointer)(c_ptr_t c_ptr_in,
>                                        gfc_array_void *f_ptr_out,
>                                        const array_t *shape,
>                                        int type, int elemSize);
>+
> /* the second param here may change, once i create the f90
>  * proc pointer.  --Rickett, 01.04.06
>  */

cheers,



More information about the Fortran mailing list