re PR fortran/77765 (ICE in gfc_match_oacc_routine, at fortran/openmp.c:1781)
authorCesar Philippidis <cesar@codesourcery.com>
Thu, 29 Jun 2017 19:03:43 +0000 (12:03 -0700)
committerCesar Philippidis <cesar@gcc.gnu.org>
Thu, 29 Jun 2017 19:03:43 +0000 (12:03 -0700)
PR fortran/77765

gcc/fortran/
* openmp.c (gfc_match_oacc_routine): Check if proc_name exist before
comparing the routine name against it.

gcc/testsuite/
* gfortran.dg/goacc/pr77765.f90: New test.

From-SVN: r249809

gcc/fortran/ChangeLog
gcc/fortran/openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/pr77765.f90 [new file with mode: 0644]

index fbf0b4ded408ad6f43acabf11845cc88c33bb6e6..e9043dd1cdf45fc179989ded357d923148a28157 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-29  Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR fortran/77765
+       * openmp.c (gfc_match_oacc_routine): Check if proc_name exist before
+       comparing the routine name against it.
+
 2017-06-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/80164
index 2b56558b7c1f9337eddee86afe88658777bd4b38..8400354181c2b9ae18965366f81928f5f4c736a1 100644 (file)
@@ -2295,7 +2295,8 @@ gfc_match_oacc_routine (void)
          if (st)
            {
              sym = st->n.sym;
-             if (strcmp (sym->name, gfc_current_ns->proc_name->name) == 0)
+             if (gfc_current_ns->proc_name != NULL
+                 && strcmp (sym->name, gfc_current_ns->proc_name->name) == 0)
                sym = NULL;
            }
 
index 8aba9c2fd41d1fb7d748b62458c3c0f2a07abdab..8fe42baf912373710e6d3d2ade973bb2df3018f5 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-29  Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR fortran/77765
+       * gfortran.dg/goacc/pr77765.f90: New test.
+
 2017-06-29  Steve Ellcey  <sellcey@cavium.com>
 
        * gcc.target/aarch64/ccmp_2.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 b/gcc/testsuite/gfortran.dg/goacc/pr77765.f90
new file mode 100644 (file)
index 0000000..3819cf7
--- /dev/null
@@ -0,0 +1,19 @@
+! Test the presence of an ACC ROUTINE directive inside a function
+! containg an error.
+
+! { dg-do compile }
+
+module m
+contains
+  recursive function f(x)
+  end function f
+  recursive function f(x)
+    !$acc routine (f)
+  end function f
+end module m
+
+! { dg-error "Procedure 'f' at .1. is already defined" "" { target *-*-* } 8 }
+! { dg-error "Duplicate RECURSIVE attribute specified" "" { target *-*-* } 8 }
+! { dg-error ".1." "" { target *-*-* } 10 }
+! { dg-error "Unexpected ..ACC ROUTINE" "" { target *-*-* } 11 }
+! { dg-error "Expecting END MODULE statement" "" { target *-*-* } 12 }