public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
@ 2016-12-12 11:56 Andre Vehreschild
  2016-12-12 12:37 ` Janus Weil
  0 siblings, 1 reply; 8+ messages in thread
From: Andre Vehreschild @ 2016-12-12 11:56 UTC (permalink / raw)
  To: GCC-Patches-ML, GCC-Fortran-ML

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Hi all,

the attached patch corrects reporting of "Sorry, unimplemented yet" for
allocatable and pointer components in polymorphic objects (BT_CLASS) thus
fixing two ICEs reported in the PR.

The next chunk fixes an ICE when the declaration containing the token
information is of type POINTER or REFERENCE.

Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?

- Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

[-- Attachment #2: pr77785_v2.clog --]
[-- Type: text/plain, Size: 505 bytes --]

gcc/fortran/ChangeLog:

2016-12-12  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77785
	* resolve.c (resolve_symbol): Correct attr lookup to the _data
	component.
	* trans-array.c (gfc_alloc_allocatable_for_assignment): Indirect ref
	pointers and references before retrieving the caf-token.

gcc/testsuite/ChangeLog:

2016-12-12  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77785
	* gfortran.dg/coarray_38.f90: Added expecting error message.
	* gfortran.dg/coarray_class_2.f90: New test.



[-- Attachment #3: pr77785_v2.patch --]
[-- Type: text/x-patch, Size: 3115 bytes --]

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2093de91..a967bfd 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14067,8 +14067,8 @@ resolve_symbol (gfc_symbol *sym)
   if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS
       && sym->ts.u.derived && CLASS_DATA (sym)
       && CLASS_DATA (sym)->attr.codimension
-      && (sym->ts.u.derived->attr.alloc_comp
-	  || sym->ts.u.derived->attr.pointer_comp))
+      && (CLASS_DATA (sym)->ts.u.derived->attr.alloc_comp
+	  || CLASS_DATA (sym)->ts.u.derived->attr.pointer_comp))
     {
       gfc_error ("Sorry, allocatable/pointer components in polymorphic (CLASS) "
 		 "type coarrays at %L are unsupported", &sym->declared_at);
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 8753cbf..0cd83f4 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9337,6 +9337,8 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
       if (token == NULL_TREE)
 	{
 	  tmp = gfc_get_tree_for_caf_expr (expr1);
+	  if (POINTER_TYPE_P (TREE_TYPE (tmp)))
+	    tmp = build_fold_indirect_ref (tmp);
 	  gfc_get_caf_token_offset (&caf_se, &token, NULL, tmp, NULL_TREE,
 				    expr1);
 	  token = gfc_build_addr_expr (NULL_TREE, token);
diff --git a/gcc/testsuite/gfortran.dg/coarray_38.f90 b/gcc/testsuite/gfortran.dg/coarray_38.f90
index c8011d4..04ef742 100644
--- a/gcc/testsuite/gfortran.dg/coarray_38.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_38.f90
@@ -92,7 +92,7 @@ end type t
 type t2
   class(t), allocatable :: caf2[:]
 end type t2
-class(t), save, allocatable :: caf[:]
+class(t), save, allocatable :: caf[:] ! { dg-error "Sorry, allocatable/pointer components in polymorphic" }
 type(t) :: x
 type(t2) :: y
 
diff --git a/gcc/testsuite/gfortran.dg/coarray_class_2.f90 b/gcc/testsuite/gfortran.dg/coarray_class_2.f90
new file mode 100644
index 0000000..58dce1a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_class_2.f90
@@ -0,0 +1,45 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! Check that error message is presented as long as polymorphic coarrays are
+! not implemented.
+
+module maccscal
+   type t
+      real, allocatable :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mptrscal
+   type t
+      real, pointer :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mallarr
+   type t
+      real, allocatable :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end
+module mptrarr
+   type t
+      real, pointer :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-12 11:56 [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990 Andre Vehreschild
@ 2016-12-12 12:37 ` Janus Weil
  2016-12-12 17:44   ` Andre Vehreschild
  0 siblings, 1 reply; 8+ messages in thread
From: Janus Weil @ 2016-12-12 12:37 UTC (permalink / raw)
  To: Andre Vehreschild; +Cc: GCC-Patches-ML, GCC-Fortran-ML

Hi Andre,

> the attached patch corrects reporting of "Sorry, unimplemented yet" for
> allocatable and pointer components in polymorphic objects (BT_CLASS) thus
> fixing two ICEs reported in the PR.
>
> The next chunk fixes an ICE when the declaration containing the token
> information is of type POINTER or REFERENCE.
>
> Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?

the resolve.c hunk is certainly ok. The trans-array.c part looks
reasonable as well, but I wonder if it is actually covered by any of
your test cases? Since they are all compile-only, with errors being
thrown at resolution stage, do they even get to the translation stage?

Cheers,
Janus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-12 12:37 ` Janus Weil
@ 2016-12-12 17:44   ` Andre Vehreschild
  2016-12-13 11:12     ` Janus Weil
  0 siblings, 1 reply; 8+ messages in thread
From: Andre Vehreschild @ 2016-12-12 17:44 UTC (permalink / raw)
  To: Janus Weil; +Cc: GCC-Patches-ML, GCC-Fortran-ML

Hi Janus,

all the sanitizer issues I fixed occur during compiling the testsuite. So I
would say, that when with the patch these errors do not occur anymore while
processing the testsuite, then those are tested for, right?

- Andre
On Mon, 12 Dec 2016 13:37:43 +0100
Janus Weil <janus@gcc.gnu.org> wrote:

> Hi Andre,
> 
> > the attached patch corrects reporting of "Sorry, unimplemented yet" for
> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus
> > fixing two ICEs reported in the PR.
> >
> > The next chunk fixes an ICE when the declaration containing the token
> > information is of type POINTER or REFERENCE.
> >
> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?  
> 
> the resolve.c hunk is certainly ok. The trans-array.c part looks
> reasonable as well, but I wonder if it is actually covered by any of
> your test cases? Since they are all compile-only, with errors being
> thrown at resolution stage, do they even get to the translation stage?
> 
> Cheers,
> Janus


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-12 17:44   ` Andre Vehreschild
@ 2016-12-13 11:12     ` Janus Weil
  2016-12-13 11:49       ` Andre Vehreschild
  2016-12-13 13:54       ` [PATCH, fortran, pr77785, v3] " Andre Vehreschild
  0 siblings, 2 replies; 8+ messages in thread
From: Janus Weil @ 2016-12-13 11:12 UTC (permalink / raw)
  To: Andre Vehreschild; +Cc: GCC-Patches-ML, GCC-Fortran-ML

Hi Andre,

> all the sanitizer issues I fixed occur during compiling the testsuite. So I
> would say, that when with the patch these errors do not occur anymore while
> processing the testsuite, then those are tested for, right?

aah, so you're saying that hunk is not actually related to the PR in
the subject line, but instead fixes a testsuite failure seen with a
sanitized compiler? That wasn't mentioned anywhere and sadly I forgot
to bring my crystal ball ...

Cheers,
Janus



> On Mon, 12 Dec 2016 13:37:43 +0100
> Janus Weil <janus@gcc.gnu.org> wrote:
>
>> Hi Andre,
>>
>> > the attached patch corrects reporting of "Sorry, unimplemented yet" for
>> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus
>> > fixing two ICEs reported in the PR.
>> >
>> > The next chunk fixes an ICE when the declaration containing the token
>> > information is of type POINTER or REFERENCE.
>> >
>> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?
>>
>> the resolve.c hunk is certainly ok. The trans-array.c part looks
>> reasonable as well, but I wonder if it is actually covered by any of
>> your test cases? Since they are all compile-only, with errors being
>> thrown at resolution stage, do they even get to the translation stage?
>>
>> Cheers,
>> Janus
>
>
> --
> Andre Vehreschild * Email: vehre ad gmx dot de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-13 11:12     ` Janus Weil
@ 2016-12-13 11:49       ` Andre Vehreschild
  2016-12-13 13:54       ` [PATCH, fortran, pr77785, v3] " Andre Vehreschild
  1 sibling, 0 replies; 8+ messages in thread
From: Andre Vehreschild @ 2016-12-13 11:49 UTC (permalink / raw)
  To: Janus Weil; +Cc: GCC-Patches-ML, GCC-Fortran-ML

Hi Janus,

no sorry. I mixed up the context. I thought your question was on pr78534. Sorry
for getting those two PRs mixed up. Just void my answer below. It is wrong. I
will see what I can do about a better testcase for the trans-array part. The
code responsible for the error unfortunately does not have a main program. So I
need to invent something.

- Andre



On Tue, 13 Dec 2016 12:11:50 +0100
Janus Weil <janus@gcc.gnu.org> wrote:

> Hi Andre,
> 
> > all the sanitizer issues I fixed occur during compiling the testsuite. So I
> > would say, that when with the patch these errors do not occur anymore while
> > processing the testsuite, then those are tested for, right?  
> 
> aah, so you're saying that hunk is not actually related to the PR in
> the subject line, but instead fixes a testsuite failure seen with a
> sanitized compiler? That wasn't mentioned anywhere and sadly I forgot
> to bring my crystal ball ...
> 
> Cheers,
> Janus
> 
> 
> 
> > On Mon, 12 Dec 2016 13:37:43 +0100
> > Janus Weil <janus@gcc.gnu.org> wrote:
> >  
> >> Hi Andre,
> >>  
> >> > the attached patch corrects reporting of "Sorry, unimplemented yet" for
> >> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus
> >> > fixing two ICEs reported in the PR.
> >> >
> >> > The next chunk fixes an ICE when the declaration containing the token
> >> > information is of type POINTER or REFERENCE.
> >> >
> >> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?  
> >>
> >> the resolve.c hunk is certainly ok. The trans-array.c part looks
> >> reasonable as well, but I wonder if it is actually covered by any of
> >> your test cases? Since they are all compile-only, with errors being
> >> thrown at resolution stage, do they even get to the translation stage?
> >>
> >> Cheers,
> >> Janus  
> >
> >
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de  


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v3] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-13 11:12     ` Janus Weil
  2016-12-13 11:49       ` Andre Vehreschild
@ 2016-12-13 13:54       ` Andre Vehreschild
  2016-12-13 15:09         ` Janus Weil
  1 sibling, 1 reply; 8+ messages in thread
From: Andre Vehreschild @ 2016-12-13 13:54 UTC (permalink / raw)
  To: Janus Weil; +Cc: GCC-Patches-ML, GCC-Fortran-ML

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

Hi Janus, hi all,

thanks for the input on the missing testcase, Janus (btw, when you know where to
get a new crystal ball, let me know; I am missing mine, too). The new version
of the patch adds a new testcase coarray_41.f90 to test that the compiler
compiles correctly and the test runs ok.

Bootstrapped and regtested on x86_64-linux/f23. Ok for trunk?

Regards,
	Andre

On Tue, 13 Dec 2016 12:11:50 +0100
Janus Weil <janus@gcc.gnu.org> wrote:

> Hi Andre,
> 
> > all the sanitizer issues I fixed occur during compiling the testsuite. So I
> > would say, that when with the patch these errors do not occur anymore while
> > processing the testsuite, then those are tested for, right?  
> 
> aah, so you're saying that hunk is not actually related to the PR in
> the subject line, but instead fixes a testsuite failure seen with a
> sanitized compiler? That wasn't mentioned anywhere and sadly I forgot
> to bring my crystal ball ...
> 
> Cheers,
> Janus
> 
> 
> 
> > On Mon, 12 Dec 2016 13:37:43 +0100
> > Janus Weil <janus@gcc.gnu.org> wrote:
> >  
> >> Hi Andre,
> >>  
> >> > the attached patch corrects reporting of "Sorry, unimplemented yet" for
> >> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus
> >> > fixing two ICEs reported in the PR.
> >> >
> >> > The next chunk fixes an ICE when the declaration containing the token
> >> > information is of type POINTER or REFERENCE.
> >> >
> >> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?  
> >>
> >> the resolve.c hunk is certainly ok. The trans-array.c part looks
> >> reasonable as well, but I wonder if it is actually covered by any of
> >> your test cases? Since they are all compile-only, with errors being
> >> thrown at resolution stage, do they even get to the translation stage?
> >>
> >> Cheers,
> >> Janus  
> >
> >
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de  


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

[-- Attachment #2: pr77785_v3.clog --]
[-- Type: text/plain, Size: 546 bytes --]

gcc/fortran/ChangeLog:

2016-12-13  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77785
	* resolve.c (resolve_symbol): Correct attr lookup to the _data
	component.
	* trans-array.c (gfc_alloc_allocatable_for_assignment): Indirect ref
	pointers and references before retrieving the caf-token.

gcc/testsuite/ChangeLog:

2016-12-13  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77785
	* gfortran.dg/coarray_38.f90: Added expecting error message.
	* gfortran.dg/coarray_41.f90: New test.
	* gfortran.dg/coarray_class_2.f90: New test.



[-- Attachment #3: pr77785_v3.patch --]
[-- Type: text/x-patch, Size: 3859 bytes --]

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index c7d872c..b610797 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14044,8 +14044,8 @@ resolve_symbol (gfc_symbol *sym)
   if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS
       && sym->ts.u.derived && CLASS_DATA (sym)
       && CLASS_DATA (sym)->attr.codimension
-      && (sym->ts.u.derived->attr.alloc_comp
-	  || sym->ts.u.derived->attr.pointer_comp))
+      && (CLASS_DATA (sym)->ts.u.derived->attr.alloc_comp
+	  || CLASS_DATA (sym)->ts.u.derived->attr.pointer_comp))
     {
       gfc_error ("Sorry, allocatable/pointer components in polymorphic (CLASS) "
 		 "type coarrays at %L are unsupported", &sym->declared_at);
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 8753cbf..0cd83f4 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9337,6 +9337,8 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
       if (token == NULL_TREE)
 	{
 	  tmp = gfc_get_tree_for_caf_expr (expr1);
+	  if (POINTER_TYPE_P (TREE_TYPE (tmp)))
+	    tmp = build_fold_indirect_ref (tmp);
 	  gfc_get_caf_token_offset (&caf_se, &token, NULL, tmp, NULL_TREE,
 				    expr1);
 	  token = gfc_build_addr_expr (NULL_TREE, token);
diff --git a/gcc/testsuite/gfortran.dg/coarray_38.f90 b/gcc/testsuite/gfortran.dg/coarray_38.f90
index c8011d4..04ef742 100644
--- a/gcc/testsuite/gfortran.dg/coarray_38.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_38.f90
@@ -92,7 +92,7 @@ end type t
 type t2
   class(t), allocatable :: caf2[:]
 end type t2
-class(t), save, allocatable :: caf[:]
+class(t), save, allocatable :: caf[:] ! { dg-error "Sorry, allocatable/pointer components in polymorphic" }
 type(t) :: x
 type(t2) :: y
 
diff --git a/gcc/testsuite/gfortran.dg/coarray_41.f90 b/gcc/testsuite/gfortran.dg/coarray_41.f90
new file mode 100644
index 0000000..b62d8e4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_41.f90
@@ -0,0 +1,29 @@
+! { dg-do run }
+! { dg-options "-fcoarray=lib -lcaf_single" }
+
+program coarray_41
+
+  integer, allocatable :: vec(:)[:,:]
+
+  allocate(vec(10)[2,*], source= 37)
+
+  if (.not. allocated(vec)) error stop
+
+  call foo(vec)
+
+  if (any(vec /= 42)) error stop
+
+  deallocate(vec)
+contains
+
+  subroutine foo(gv)
+
+    integer, allocatable, intent(inout) :: gv(:)[:,:]
+    integer, allocatable :: gvin(:)
+
+    allocate(gvin, mold=gv)
+    gvin = 5
+    gv = gv + gvin
+  end subroutine foo
+
+end program coarray_41
diff --git a/gcc/testsuite/gfortran.dg/coarray_class_2.f90 b/gcc/testsuite/gfortran.dg/coarray_class_2.f90
new file mode 100644
index 0000000..58dce1a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_class_2.f90
@@ -0,0 +1,45 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! Check that error message is presented as long as polymorphic coarrays are
+! not implemented.
+
+module maccscal
+   type t
+      real, allocatable :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mptrscal
+   type t
+      real, pointer :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mallarr
+   type t
+      real, allocatable :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end
+module mptrarr
+   type t
+      real, pointer :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v3] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-13 13:54       ` [PATCH, fortran, pr77785, v3] " Andre Vehreschild
@ 2016-12-13 15:09         ` Janus Weil
  2016-12-13 16:48           ` Andre Vehreschild
  0 siblings, 1 reply; 8+ messages in thread
From: Janus Weil @ 2016-12-13 15:09 UTC (permalink / raw)
  To: Andre Vehreschild; +Cc: GCC-Patches-ML, GCC-Fortran-ML

Hi Andre,

> thanks for the input on the missing testcase, Janus (btw, when you know where to
> get a new crystal ball, let me know; I am missing mine, too). The new version
> of the patch adds a new testcase coarray_41.f90 to test that the compiler
> compiles correctly and the test runs ok.
>
> Bootstrapped and regtested on x86_64-linux/f23. Ok for trunk?

yes, good for trunk then.

Cheers,
Janus



> On Tue, 13 Dec 2016 12:11:50 +0100
> Janus Weil <janus@gcc.gnu.org> wrote:
>
>> Hi Andre,
>>
>> > all the sanitizer issues I fixed occur during compiling the testsuite. So I
>> > would say, that when with the patch these errors do not occur anymore while
>> > processing the testsuite, then those are tested for, right?
>>
>> aah, so you're saying that hunk is not actually related to the PR in
>> the subject line, but instead fixes a testsuite failure seen with a
>> sanitized compiler? That wasn't mentioned anywhere and sadly I forgot
>> to bring my crystal ball ...
>>
>> Cheers,
>> Janus
>>
>>
>>
>> > On Mon, 12 Dec 2016 13:37:43 +0100
>> > Janus Weil <janus@gcc.gnu.org> wrote:
>> >
>> >> Hi Andre,
>> >>
>> >> > the attached patch corrects reporting of "Sorry, unimplemented yet" for
>> >> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus
>> >> > fixing two ICEs reported in the PR.
>> >> >
>> >> > The next chunk fixes an ICE when the declaration containing the token
>> >> > information is of type POINTER or REFERENCE.
>> >> >
>> >> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?
>> >>
>> >> the resolve.c hunk is certainly ok. The trans-array.c part looks
>> >> reasonable as well, but I wonder if it is actually covered by any of
>> >> your test cases? Since they are all compile-only, with errors being
>> >> thrown at resolution stage, do they even get to the translation stage?
>> >>
>> >> Cheers,
>> >> Janus
>> >
>> >
>> > --
>> > Andre Vehreschild * Email: vehre ad gmx dot de
>
>
> --
> Andre Vehreschild * Email: vehre ad gmx dot de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, fortran, pr77785, v3] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990
  2016-12-13 15:09         ` Janus Weil
@ 2016-12-13 16:48           ` Andre Vehreschild
  0 siblings, 0 replies; 8+ messages in thread
From: Andre Vehreschild @ 2016-12-13 16:48 UTC (permalink / raw)
  To: Janus Weil; +Cc: GCC-Patches-ML, GCC-Fortran-ML

[-- Attachment #1: Type: text/plain, Size: 2356 bytes --]

Hi Janus,

thanks for the review. Committed as r243614.

- Andre

On Tue, 13 Dec 2016 16:08:59 +0100
Janus Weil <janus@gcc.gnu.org> wrote:

> Hi Andre,
> 
> > thanks for the input on the missing testcase, Janus (btw, when you know
> > where to get a new crystal ball, let me know; I am missing mine, too). The
> > new version of the patch adds a new testcase coarray_41.f90 to test that
> > the compiler compiles correctly and the test runs ok.
> >
> > Bootstrapped and regtested on x86_64-linux/f23. Ok for trunk?  
> 
> yes, good for trunk then.
> 
> Cheers,
> Janus
> 
> 
> 
> > On Tue, 13 Dec 2016 12:11:50 +0100
> > Janus Weil <janus@gcc.gnu.org> wrote:
> >  
> >> Hi Andre,
> >>  
> >> > all the sanitizer issues I fixed occur during compiling the testsuite.
> >> > So I would say, that when with the patch these errors do not occur
> >> > anymore while processing the testsuite, then those are tested for,
> >> > right?  
> >>
> >> aah, so you're saying that hunk is not actually related to the PR in
> >> the subject line, but instead fixes a testsuite failure seen with a
> >> sanitized compiler? That wasn't mentioned anywhere and sadly I forgot
> >> to bring my crystal ball ...
> >>
> >> Cheers,
> >> Janus
> >>
> >>
> >>  
> >> > On Mon, 12 Dec 2016 13:37:43 +0100
> >> > Janus Weil <janus@gcc.gnu.org> wrote:
> >> >  
> >> >> Hi Andre,
> >> >>  
> >> >> > the attached patch corrects reporting of "Sorry, unimplemented yet"
> >> >> > for allocatable and pointer components in polymorphic objects
> >> >> > (BT_CLASS) thus fixing two ICEs reported in the PR.
> >> >> >
> >> >> > The next chunk fixes an ICE when the declaration containing the token
> >> >> > information is of type POINTER or REFERENCE.
> >> >> >
> >> >> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk?  
> >> >>
> >> >> the resolve.c hunk is certainly ok. The trans-array.c part looks
> >> >> reasonable as well, but I wonder if it is actually covered by any of
> >> >> your test cases? Since they are all compile-only, with errors being
> >> >> thrown at resolution stage, do they even get to the translation stage?
> >> >>
> >> >> Cheers,
> >> >> Janus  
> >> >
> >> >
> >> > --
> >> > Andre Vehreschild * Email: vehre ad gmx dot de  
> >
> >
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de  


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 5027 bytes --]

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 243613)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,11 @@
+2016-12-13  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+	PR fortran/77785
+	* resolve.c (resolve_symbol): Correct attr lookup to the _data
+	component.
+	* trans-array.c (gfc_alloc_allocatable_for_assignment): Indirect ref
+	pointers and references before retrieving the caf-token.
+
 2016-12-13  Janus Weil  <janus@gcc.gnu.org>
 	    Paul Thomas  <pault@gcc.gnu.org>
 
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 243613)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -14044,8 +14044,8 @@
   if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS
       && sym->ts.u.derived && CLASS_DATA (sym)
       && CLASS_DATA (sym)->attr.codimension
-      && (sym->ts.u.derived->attr.alloc_comp
-	  || sym->ts.u.derived->attr.pointer_comp))
+      && (CLASS_DATA (sym)->ts.u.derived->attr.alloc_comp
+	  || CLASS_DATA (sym)->ts.u.derived->attr.pointer_comp))
     {
       gfc_error ("Sorry, allocatable/pointer components in polymorphic (CLASS) "
 		 "type coarrays at %L are unsupported", &sym->declared_at);
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c	(Revision 243613)
+++ gcc/fortran/trans-array.c	(Arbeitskopie)
@@ -9337,6 +9337,8 @@
       if (token == NULL_TREE)
 	{
 	  tmp = gfc_get_tree_for_caf_expr (expr1);
+	  if (POINTER_TYPE_P (TREE_TYPE (tmp)))
+	    tmp = build_fold_indirect_ref (tmp);
 	  gfc_get_caf_token_offset (&caf_se, &token, NULL, tmp, NULL_TREE,
 				    expr1);
 	  token = gfc_build_addr_expr (NULL_TREE, token);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 243613)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,10 @@
+2016-12-13  Andre Vehreschild  <vehre@gcc.gnu.org>
+
+	PR fortran/77785
+	* gfortran.dg/coarray_38.f90: Added expecting error message.
+	* gfortran.dg/coarray_41.f90: New test.
+	* gfortran.dg/coarray_class_2.f90: New test.
+
 2016-12-13 Carl Love  <cel@us.ibm.com>
 
 	* gcc.target/powerpc/builtins-3.c: Add new test of the test suite
Index: gcc/testsuite/gfortran.dg/coarray_38.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_38.f90	(Revision 243613)
+++ gcc/testsuite/gfortran.dg/coarray_38.f90	(Arbeitskopie)
@@ -92,7 +92,7 @@
 type t2
   class(t), allocatable :: caf2[:]
 end type t2
-class(t), save, allocatable :: caf[:]
+class(t), save, allocatable :: caf[:] ! { dg-error "Sorry, allocatable/pointer components in polymorphic" }
 type(t) :: x
 type(t2) :: y
 
Index: gcc/testsuite/gfortran.dg/coarray_41.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_41.f90	(nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_41.f90	(Arbeitskopie)
@@ -0,0 +1,29 @@
+! { dg-do run }
+! { dg-options "-fcoarray=lib -lcaf_single" }
+
+program coarray_41
+
+  integer, allocatable :: vec(:)[:,:]
+
+  allocate(vec(10)[2,*], source= 37)
+
+  if (.not. allocated(vec)) error stop
+
+  call foo(vec)
+
+  if (any(vec /= 42)) error stop
+
+  deallocate(vec)
+contains
+
+  subroutine foo(gv)
+
+    integer, allocatable, intent(inout) :: gv(:)[:,:]
+    integer, allocatable :: gvin(:)
+
+    allocate(gvin, mold=gv)
+    gvin = 5
+    gv = gv + gvin
+  end subroutine foo
+
+end program coarray_41
Index: gcc/testsuite/gfortran.dg/coarray_class_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_class_2.f90	(nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_class_2.f90	(Arbeitskopie)
@@ -0,0 +1,45 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! Check that error message is presented as long as polymorphic coarrays are
+! not implemented.
+
+module maccscal
+   type t
+      real, allocatable :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mptrscal
+   type t
+      real, pointer :: a
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a)
+   end
+end
+module mallarr
+   type t
+      real, allocatable :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end
+module mptrarr
+   type t
+      real, pointer :: a(:)
+   end type
+contains
+   subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" }
+      class(t) :: x[*]
+      allocate (x%a(2))
+   end
+end

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-13 16:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 11:56 [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990 Andre Vehreschild
2016-12-12 12:37 ` Janus Weil
2016-12-12 17:44   ` Andre Vehreschild
2016-12-13 11:12     ` Janus Weil
2016-12-13 11:49       ` Andre Vehreschild
2016-12-13 13:54       ` [PATCH, fortran, pr77785, v3] " Andre Vehreschild
2016-12-13 15:09         ` Janus Weil
2016-12-13 16:48           ` Andre Vehreschild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).