Patchwork Fix up one OpenMP Fortran OOP ICE (PR fortran/56052)

login
register
mail settings
Submitter Jakub Jelinek
Date Jan. 22, 2013, 4:38 p.m.
Message ID <20130122163810.GV7269@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/214597/
State New
Headers show

Comments

Jakub Jelinek - Jan. 22, 2013, 4:38 p.m.
Hi!

Fortran OOP is still to be considered completely unsupported in OpenMP,
but this patch just attempts to fix this because it was easy to do so.
The select_type_temporary vars are artificial (created by the compiler,
not user vars), we shouldn't emit them into debug info, nor they should be
privatized by reference.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/56052
	* trans-decl.c (gfc_get_symbol_decl): Set DECL_ARTIFICIAL
	and DECL_IGNORED_P on select_type_temporary and don't set
	DECL_BY_REFERENCE.

	* gfortran.dg/gomp/pr56052.f90: New test.


	Jakub
Janus Weil - Jan. 23, 2013, 8:38 a.m.
Hi Jakub,

> Fortran OOP is still to be considered completely unsupported in OpenMP,
> but this patch just attempts to fix this because it was easy to do so.
> The select_type_temporary vars are artificial (created by the compiler,
> not user vars), we shouldn't emit them into debug info, nor they should be
> privatized by reference.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

looks good to me. Thanks for the patch! Maybe you also wanna backport
this to 4.7?

Cheers,
Janus



> 2013-01-22  Jakub Jelinek  <jakub@redhat.com>
>
>         PR fortran/56052
>         * trans-decl.c (gfc_get_symbol_decl): Set DECL_ARTIFICIAL
>         and DECL_IGNORED_P on select_type_temporary and don't set
>         DECL_BY_REFERENCE.
>
>         * gfortran.dg/gomp/pr56052.f90: New test.
>
> --- gcc/fortran/trans-decl.c.jj 2013-01-11 09:02:50.000000000 +0100
> +++ gcc/fortran/trans-decl.c    2013-01-21 18:11:39.684529593 +0100
> @@ -1397,6 +1397,12 @@ gfc_get_symbol_decl (gfc_symbol * sym)
>         DECL_IGNORED_P (decl) = 1;
>      }
>
> +  if (sym->attr.select_type_temporary)
> +    {
> +      DECL_ARTIFICIAL (decl) = 1;
> +      DECL_IGNORED_P (decl) = 1;
> +    }
> +
>    if (sym->attr.dimension || sym->attr.codimension)
>      {
>        /* Create variables to hold the non-constant bits of array info.  */
> @@ -1496,7 +1502,8 @@ gfc_get_symbol_decl (gfc_symbol * sym)
>        && POINTER_TYPE_P (TREE_TYPE (decl))
>        && !sym->attr.pointer
>        && !sym->attr.allocatable
> -      && !sym->attr.proc_pointer)
> +      && !sym->attr.proc_pointer
> +      && !sym->attr.select_type_temporary)
>      DECL_BY_REFERENCE (decl) = 1;
>
>    if (sym->attr.vtab
> --- gcc/testsuite/gfortran.dg/gomp/pr56052.f90.jj       2013-01-21 18:14:38.716547446 +0100
> +++ gcc/testsuite/gfortran.dg/gomp/pr56052.f90  2013-01-21 18:14:59.425432249 +0100
> @@ -0,0 +1,16 @@
> +! PR fortran/56052
> +! { dg-do compile }
> +! { dg-options "-fopenmp" }
> +
> +subroutine middle(args)
> +  type args_t
> +  end type
> +  type, extends(args_t) :: scan_args_t
> +  end type
> +  class(args_t),intent(inout) :: args
> +  !$omp single
> +    select type (args)
> +      type is (scan_args_t)
> +    end select
> +  !$omp end single
> +end subroutine middle
>
>         Jakub

Patch

--- gcc/fortran/trans-decl.c.jj	2013-01-11 09:02:50.000000000 +0100
+++ gcc/fortran/trans-decl.c	2013-01-21 18:11:39.684529593 +0100
@@ -1397,6 +1397,12 @@  gfc_get_symbol_decl (gfc_symbol * sym)
 	DECL_IGNORED_P (decl) = 1;
     }
 
+  if (sym->attr.select_type_temporary)
+    {
+      DECL_ARTIFICIAL (decl) = 1;
+      DECL_IGNORED_P (decl) = 1;
+    }
+
   if (sym->attr.dimension || sym->attr.codimension)
     {
       /* Create variables to hold the non-constant bits of array info.  */
@@ -1496,7 +1502,8 @@  gfc_get_symbol_decl (gfc_symbol * sym)
       && POINTER_TYPE_P (TREE_TYPE (decl))
       && !sym->attr.pointer
       && !sym->attr.allocatable
-      && !sym->attr.proc_pointer)
+      && !sym->attr.proc_pointer
+      && !sym->attr.select_type_temporary)
     DECL_BY_REFERENCE (decl) = 1;
 
   if (sym->attr.vtab
--- gcc/testsuite/gfortran.dg/gomp/pr56052.f90.jj	2013-01-21 18:14:38.716547446 +0100
+++ gcc/testsuite/gfortran.dg/gomp/pr56052.f90	2013-01-21 18:14:59.425432249 +0100
@@ -0,0 +1,16 @@ 
+! PR fortran/56052
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+subroutine middle(args)
+  type args_t
+  end type
+  type, extends(args_t) :: scan_args_t
+  end type
+  class(args_t),intent(inout) :: args
+  !$omp single
+    select type (args)
+      type is (scan_args_t)
+    end select
+  !$omp end single
+end subroutine middle