public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [Patch, Fortran, 66927, v2] [6 Regression] ICE in gfc_conf_procedure_call
@ 2015-10-25 11:51 Paul Richard Thomas
  2015-10-25 13:09 ` Andre Vehreschild
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2015-10-25 11:51 UTC (permalink / raw)
  To: Dominique d'Humières, gcc-patches
  Cc: Andre Vehreschild, Mikael Morin, GNU GFortran

Dear Andre,

As far as I can see, the problems with PR57117 are specific to RESHAPE
and need not affect committing your patch. To my surprise, the
combination of your patch and mine for PR67171 fixes PR67044 in that
the ICE no longer occurs. I have to get my head around how to write a
testcase for it that tests the functionality though!

You can commit this patch to trunk. As I said elsewhere, I will rename
the testcase for PR67171.

Many thanks for the patch.

Paul

On 23 October 2015 at 09:44, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Dear Andre,
>
> I will wait until you fix the problems that Dominique has pointed out.
> However, if by Sunday afternoon (rain forecast!) you haven't found the
> time, I will see if I can locate the source of these new problems.
>
> With best regards
>
> Paul
>
> On 7 October 2015 at 19:51, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
>> This patch also fixes pr57117 comment 2, the original test and the test in comment 3 now give an ICE
>>
>> pr57117.f90:82:0:
>>
>>    allocate(z(9), source=reshape(x, (/ 9 /)))
>> 1
>> internal compiler error: Segmentation fault: 11
>>
>> and pr67044.
>>
>> Thanks,
>>
>> Dominique
>>
>
>
>
> --
> Outside of a dog, a book is a man's best friend. Inside of a dog it's
> too dark to read.
>
> Groucho Marx



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [Patch, Fortran, 66927, v2] [6 Regression] ICE in gfc_conf_procedure_call
@ 2015-10-07 17:51 Dominique d'Humières
  0 siblings, 0 replies; 7+ messages in thread
From: Dominique d'Humières @ 2015-10-07 17:51 UTC (permalink / raw)
  To: Andre Vehreschild
  Cc: Mikael Morin, Paul Richard Thomas, GNU GFortran, GCC Patches

This patch also fixes pr57117 comment 2, the original test and the test in comment 3 now give an ICE

pr57117.f90:82:0:

   allocate(z(9), source=reshape(x, (/ 9 /)))
1
internal compiler error: Segmentation fault: 11

and pr67044.

Thanks,

Dominique

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Patch, Fortran, 66927, v1]  [6 Regression] ICE in gfc_conf_procedure_call
@ 2015-08-06 10:53 Andre Vehreschild
  2015-08-06 12:01 ` Mikael Morin
  0 siblings, 1 reply; 7+ messages in thread
From: Andre Vehreschild @ 2015-08-06 10:53 UTC (permalink / raw)
  To: GCC-Patches-ML, GCC-Fortran-ML

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

Dear all,

the attached patch fixes a regression introduced by my patches for the
F2008-style allocate(). In this case a function returning an array of BT_CLASS
objects can not be conv'ed using conv_expr_descriptor, but needs to be
conv_expr_reference()'ed, because the _data component has the descriptor already
and just needs to be addressed correctly.

Bootstraps and regtests ok on x86_64-linux-gnu/f21.

Ok for trunk?

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

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

gcc/fortran/ChangeLog:

2015-08-06  Andre Vehreschild  <vehre@gcc.gnu.org>

	* trans-stmt.c (gfc_trans_allocate): Do not conv_expr_descriptor
	for functions returning	a class object. Get the reference
	instead.

gcc/testsuite/ChangeLog:

2015-08-06  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/allocate_with_source_10.f08: New test.



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

diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 6409f7f..3f90b76 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -5187,9 +5187,14 @@ gfc_trans_allocate (gfc_code * code)
 	  /* In all other cases evaluate the expr3.  */
 	  symbol_attribute attr;
 	  /* Get the descriptor for all arrays, that are not allocatable or
-	     pointer, because the latter are descriptors already.  */
+	     pointer, because the latter are descriptors already.
+	     The exception are function calls returning a class object:
+	     For those conv_expr_descriptor does not work.  */
 	  attr = gfc_expr_attr (code->expr3);
-	  if (code->expr3->rank != 0 && !attr.allocatable && !attr.pointer)
+	  if (code->expr3->rank != 0
+	      && ((!attr.allocatable && !attr.pointer)
+		  || (code->expr3->expr_type == EXPR_FUNCTION
+		      && code->expr3->ts.type != BT_CLASS)))
 	    gfc_conv_expr_descriptor (&se, code->expr3);
 	  else
 	    gfc_conv_expr_reference (&se, code->expr3);
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_10.f08 b/gcc/testsuite/gfortran.dg/allocate_with_source_10.f08
new file mode 100644
index 0000000..88962c1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_10.f08
@@ -0,0 +1,52 @@
+!{ dg-do run }
+!
+! Testcase for pr66927
+! Contributed by Juergen Reuter <juergen.reuter@desy.de>
+
+module processes
+  implicit none
+  private
+
+  type :: t1_t
+     real :: p = 0.0
+  end type t1_t
+  
+  type :: t2_t
+     private
+     type(t1_t), dimension(:), allocatable :: p
+   contains
+     procedure :: func => t2_func
+  end type t2_t
+  
+  type, public :: t3_t
+    type(t2_t), public :: int_born
+  end type t3_t
+
+  public :: evaluate
+
+contains
+
+  function t2_func (int) result (p)
+    class(t2_t), intent(in) :: int
+    type(t1_t), dimension(:), allocatable :: p
+    allocate(p(5))
+  end function t2_func
+  
+  subroutine evaluate (t3)
+    class(t3_t), intent(inout) :: t3
+    type(t1_t), dimension(:), allocatable :: p_born    
+    allocate (p_born(1:size(t3%int_born%func ())), &
+         source = t3%int_born%func ())
+    if (.not. allocated(p_born)) call abort()
+    if (size(p_born) /= 5) call abort()
+  end subroutine evaluate
+
+end module processes
+
+program pr66927
+use processes
+type(t3_t) :: o
+call evaluate(o)
+end
+
+

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

end of thread, other threads:[~2015-10-26 13:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-25 11:51 [Patch, Fortran, 66927, v2] [6 Regression] ICE in gfc_conf_procedure_call Paul Richard Thomas
2015-10-25 13:09 ` Andre Vehreschild
2015-10-26 10:05   ` [Patch, Fortran, 66927, v2.1] " Andre Vehreschild
2015-10-26 12:06     ` Paul Richard Thomas
2015-10-26 13:07       ` Andre Vehreschild
  -- strict thread matches above, loose matches on Subject: below --
2015-10-07 17:51 [Patch, Fortran, 66927, v2] " Dominique d'Humières
2015-08-06 10:53 [Patch, Fortran, 66927, v1] " Andre Vehreschild
2015-08-06 12:01 ` Mikael Morin
2015-08-09 12:37   ` Mikael Morin
2015-09-29 14:27     ` [Patch, Fortran, 66927, v2] " 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).