]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/35031 (ELEMENTAL procedure with BIND(C))
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 12 Jan 2019 00:33:01 +0000 (00:33 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 12 Jan 2019 00:33:01 +0000 (00:33 +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: r267874

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

index e12b57709616840a7490721ec32d5bd60d2f990f..1a00f9411f8a34bbd54bed30d1445e6c0a6360e8 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.
+
 2018-12-29  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from trunk
index 42879f063e2c190b9889f7eeeabf45a770e99f87..2f69028ac2c060e7f4089cf204ee6c49a60058ff 100644 (file)
@@ -6479,9 +6479,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
@@ -6565,6 +6567,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 f4b6678f203b0aa7b0c64905c5a89b37e60661ee..80317b36aa348530af17099c0239a34bc9a6dfb3 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-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.target/sparc/tls-ld-int8.c: New test.
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