decl.c (gfc_verify_c_interop_param): Allow assumed-shape with -std=f2008ts.
authorTobias Burnus <burnus@net-b.de>
Fri, 20 Jul 2012 20:15:59 +0000 (22:15 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 20 Jul 2012 20:15:59 +0000 (22:15 +0200)
2012-07-20  Tobias Burnus  <burnus@net-b.de>

        * decl.c (gfc_verify_c_interop_param): Allow assumed-shape
        with -std=f2008ts.

2012-07-20  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/bind_c_array_params_2.f90: New.
        * gfortran.dg/bind_c_array_params.f03: Add -std=f2003
        and update dg-error.

From-SVN: r189726

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/bind_c_array_params.f03
gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 [new file with mode: 0644]

index 0d8b4bacc272f77781bd1f43f1f95836447b2784..f8558a67a3a714d5f6b7d27b3bd4b02590801485 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-20  Tobias Burnus  <burnus@net-b.de>
+
+       * decl.c (gfc_verify_c_interop_param): Allow assumed-shape
+       with -std=f2008ts.
+
 2012-07-20  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/48820
index 66e2ca86c7ae9e778415c148d0725061e9bff9cc..28e5a5b4aedb6fb05fd16efd4aa1695b3d99f3ee 100644 (file)
@@ -1095,29 +1095,15 @@ gfc_verify_c_interop_param (gfc_symbol *sym)
            retval = FAILURE;
 
           /* Make sure that if it has the dimension attribute, that it is
-            either assumed size or explicit shape.  */
-         if (sym->as != NULL)
-           {
-             if (sym->as->type == AS_ASSUMED_SHAPE)
-               {
-                 gfc_error ("Assumed-shape array '%s' at %L cannot be an "
-                            "argument to the procedure '%s' at %L because "
-                            "the procedure is BIND(C)", sym->name,
-                            &(sym->declared_at), sym->ns->proc_name->name,
-                            &(sym->ns->proc_name->declared_at));
-                 retval = FAILURE;
-               }
-
-             if (sym->as->type == AS_DEFERRED)
-               {
-                 gfc_error ("Deferred-shape array '%s' at %L cannot be an "
-                            "argument to the procedure '%s' at %L because "
-                            "the procedure is BIND(C)", sym->name,
-                            &(sym->declared_at), sym->ns->proc_name->name,
-                            &(sym->ns->proc_name->declared_at));
-                 retval = FAILURE;
-               }
-         }
+            either assumed size or explicit shape. Deferred shape is already
+            covered by the pointer/allocatable attribute.  */
+         if (sym->as != NULL && sym->as->type == AS_ASSUMED_SHAPE
+             && gfc_notify_std (GFC_STD_F2008_TS, "Assumed-shape array '%s' "
+                             "at %L as dummy argument to the BIND(C) "
+                             "procedure '%s' at %L", sym->name,
+                             &(sym->declared_at), sym->ns->proc_name->name,
+                             &(sym->ns->proc_name->declared_at)) == FAILURE)
+           retval = FAILURE;
        }
     }
 
index ee773e8c65af38d9daf10c9e7289ad3d4a1b044c..1b49f13f6061957376e18e64f15419c2cc96429a 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-20  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/bind_c_array_params_2.f90: New.
+       * gfortran.dg/bind_c_array_params.f03: Add -std=f2003
+       and update dg-error.
+
 2012-07-20  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/assumed_rank_12.f90: Update dg-error.
index 6590db1d1d69341f2a5b489d169fda6fe7c09ea6..810f64277ccef411ca88b1eaf3036afe24ae8da0 100644 (file)
@@ -1,10 +1,11 @@
 ! { dg-do compile }
+! { dg-options "-std=f2003" }
 module bind_c_array_params
 use, intrinsic :: iso_c_binding
 implicit none
 
 contains
-  subroutine sub0(assumed_array) bind(c) ! { dg-error "cannot be an argument" }
+  subroutine sub0(assumed_array) bind(c) ! { dg-error "TS 29113: Assumed-shape array 'assumed_array' at .1. as dummy argument to the BIND.C. procedure 'sub0'" }
     integer(c_int), dimension(:) :: assumed_array
   end subroutine sub0
 
diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
new file mode 100644 (file)
index 0000000..b6c8429
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-std=f2008ts -fdump-tree-original" }
+!
+! Check that assumed-shape variables are correctly passed to BIND(C)
+! as defined in TS 29913
+! 
+interface
+  subroutine test (xx) bind(C, name="myBindC")
+    type(*), dimension(:,:) :: xx
+  end subroutine test
+end interface
+
+integer :: aa(4,4)
+call test(aa)
+end
+
+! { dg-final { scan-tree-dump-times "test \\\(&parm\\." 1 "original" } }
+! { dg-final { scan-assembler-times "myBindC" 1 } }
+