re PR fortran/35031 (ELEMENTAL procedure with BIND(C))
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 Jan 2019 23:41:04 +0000 (23:41 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 Jan 2019 23:41:04 +0000 (23:41 +0000)
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/35031
* decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
mis-indentation.

2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/35031
* gfortran.dg/pr35031.f90: new test.

From-SVN: r267864

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

index c54da9dc2749a3a6150648d5c0153f3062d48911..b05c594d0775292eebab8ce395a2000ed50dd91b 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/35031
+       * decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
+       mis-indentation.
+
 2019-01-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/85956
index e5bfc3bd5a4d5597524485566c4f497a7c1adc7e..3314e176881e422ab951e6fa51bd8ec061eb1461 100644 (file)
@@ -7431,9 +7431,11 @@ gfc_match_entry (void)
              gfc_error ("Missing required parentheses before BIND(C) at %C");
              return MATCH_ERROR;
            }
-           if (!gfc_add_is_bind_c (&(entry->attr), entry->name,
-                                   &(entry->declared_at), 1))
-             return MATCH_ERROR;
+
+         if (!gfc_add_is_bind_c (&(entry->attr), entry->name,
+                                 &(entry->declared_at), 1))
+           return MATCH_ERROR;
+       
        }
 
       if (!gfc_current_ns->parent
@@ -7517,6 +7519,14 @@ gfc_match_entry (void)
       return MATCH_ERROR;
     }
 
+  /* F2018:C1546 An elemental procedure shall not have the BIND attribute.  */
+  if (proc->attr.elemental && entry->attr.is_bind_c)
+    {
+      gfc_error ("ENTRY statement at %L with BIND(C) prohibited in an "
+                "elemental procedure", &entry->declared_at);
+      return MATCH_ERROR;
+    }
+
   entry->attr.recursive = proc->attr.recursive;
   entry->attr.elemental = proc->attr.elemental;
   entry->attr.pure = proc->attr.pure;
index 11845e3d0cc05cf264d6edd8870001a36b9dd441..8b8ebc8156d0369889d258ec7df6776b7070f496 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/35031
+       * gfortran.dg/pr35031.f90: new test.
+
 2019-01-11  Marek Polacek  <polacek@redhat.com>
 
        PR c++/88692, c++/87882 - -Wredundant-move false positive with *this.
diff --git a/gcc/testsuite/gfortran.dg/pr35031.f90 b/gcc/testsuite/gfortran.dg/pr35031.f90
new file mode 100644 (file)
index 0000000..a4d7840
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+elemental subroutine sub2(x)
+   integer, intent(in) :: x
+   entry sub2_c(x) bind(c)    ! { dg-error "prohibited in an elemental" }
+end subroutine sub2
+
+elemental function func2(x)
+   integer, intent(in) :: x
+   entry func2_c(x) bind(c)   ! { dg-error "prohibited in an elemental" }
+end function func2