[Fortran] avoid ICE in gfc_omp_check_optional_argument (PR93464)
authorTobias Burnus <tobias@codesourcery.com>
Tue, 28 Jan 2020 10:54:57 +0000 (11:54 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 28 Jan 2020 11:01:52 +0000 (12:01 +0100)
        PR fortran/93464
        * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when
        DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not
        GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars.

        PR fortran/93464
        * gfortran.dg/goacc/pr93464.f90: New.

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

index 4040ff284b3e647eb2da6ba4bf50162c4022417c..eb8842b0ab893d2362d8ab336e49bb14e375d366 100644 (file)
@@ -1,3 +1,10 @@
+2020-01-28  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93464
+       * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when
+       DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not
+       GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars.
+
 2020-01-28  Tobias Burnus  <tobias@codesourcery.com>
 
        * gfortran.texi (Runtime): Remove tailing '.' in @menu.
index fd60bbbed5de1e1686973ef0053a97514b9d3d69..66669550499c4277c595c65f2caa1c8c7e757b2e 100644 (file)
@@ -101,7 +101,8 @@ gfc_omp_check_optional_argument (tree decl, bool for_present_check)
       decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
     }
 
-  if (TREE_CODE (decl) != PARM_DECL
+  if (decl == NULL_TREE
+      || TREE_CODE (decl) != PARM_DECL
       || !DECL_LANG_SPECIFIC (decl)
       || !GFC_DECL_OPTIONAL_ARGUMENT (decl))
     return NULL_TREE;
index eac18206b1229792913fc74672eb414f16d7ad7b..d9441cb0a2ef95379333dfcef619e3b4d1a5810b 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-28  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93464
+       * gfortran.dg/goacc/pr93464.f90: New.
+
 2020-01-28  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/93434
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
new file mode 100644 (file)
index 0000000..9221065
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile }
+!
+! PR fortran/93464
+!
+! Contributed by G. Steinmetz
+!
+program p
+   character :: c(2) = 'a'
+   character, allocatable :: z(:)
+   !$acc parallel
+   !$omp target
+   z = c
+   !$acc end parallel
+   !$omp end target
+   print *, z
+end