[Patch, Fortran] PR 35831: Checking characteristics of dummy arguments

Janus Weil janus@gcc.gnu.org
Tue Dec 10 21:17:00 GMT 2013


Hi all,

here is a straightforward patch for a rather old PR, which deals with
argument checking. The patch at hand fixes one of the outstanding todo
items of the PR (see comment 17), namely extending the attribute
checking of dummy arguments. It adds checks for the four missing
attributes (asynchronous, contiguous, value, volatile). The relevant
standard reference is F08:12.3.2.

Included is also a test case and a fix for one testsuite case which
was rejected with the patch.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus



2013-12-10  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/35831
    * interface.c (check_dummy_characteristics): Add checks for several
    attributes.


2013-12-10  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/35831
    * gfortran.dg/c_by_val_5.f90: Modified.
    * gfortran.dg/dummy_procedure_10.f90: New.
-------------- next part --------------
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 205870)
+++ gcc/fortran/interface.c	(working copy)
@@ -1114,9 +1114,38 @@ check_dummy_characteristics (gfc_symbol *s1, gfc_s
       return false;
     }
 
-  /* FIXME: Do more comprehensive testing of attributes, like e.g.
-	    ASYNCHRONOUS, CONTIGUOUS, VALUE, VOLATILE, etc.  */
+  /* Check ASYNCHRONOUS attribute.  */
+  if (s1->attr.asynchronous != s2->attr.asynchronous)
+    {
+      snprintf (errmsg, err_len, "ASYNCHRONOUS mismatch in argument '%s'",
+		s1->name);
+      return false;
+    }
 
+  /* Check CONTIGUOUS attribute.  */
+  if (s1->attr.contiguous != s2->attr.contiguous)
+    {
+      snprintf (errmsg, err_len, "CONTIGUOUS mismatch in argument '%s'",
+		s1->name);
+      return false;
+    }
+
+  /* Check VALUE attribute.  */
+  if (s1->attr.value != s2->attr.value)
+    {
+      snprintf (errmsg, err_len, "VALUE mismatch in argument '%s'",
+		s1->name);
+      return false;
+    }
+
+  /* Check VOLATILE attribute.  */
+  if (s1->attr.volatile_ != s2->attr.volatile_)
+    {
+      snprintf (errmsg, err_len, "VOLATILE mismatch in argument '%s'",
+		s1->name);
+      return false;
+    }
+
   /* Check interface of dummy procedures.  */
   if (s1->attr.flavor == FL_PROCEDURE)
     {
Index: gcc/testsuite/gfortran.dg/c_by_val_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/c_by_val_5.f90	(revision 205870)
+++ gcc/testsuite/gfortran.dg/c_by_val_5.f90	(working copy)
@@ -23,7 +23,7 @@ module x
  ! "external" only.
  interface
    subroutine bmp_write(nx)
-     integer :: nx
+     integer, value :: nx
    end subroutine bmp_write
  end interface
 contains
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dummy_procedure_10.f90
Type: text/x-fortran
Size: 1185 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20131210/c3f41bd9/attachment.bin>


More information about the Fortran mailing list