public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem
@ 2016-01-25 21:03 Paul Richard Thomas
  2016-01-25 21:13 ` Janus Weil
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2016-01-25 21:03 UTC (permalink / raw)
  To: fortran, gcc-patches, Janus Weil

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

Dear All,

The initial report concerns initialization assignments that should be
excluded from the check for assignment of scalars to unallocated
arrays. This part is so trivial that it does not require a test. On
the other hand, the block that implemented the check was plain and
simple wrong and the rest of the patch corrects this. It is commented
such as to be fully comprehensible.

Bootstrapped and regtested on FC21/x86_64 - OK for trunk and for
5-branch when all the wrinkles (PR69422 and 69423) are sorted out?

Cheers

Paul

2016-01-25  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/69385
    * trans-expr.c (gfc_trans_assignment_1): Exclude initialization
    assignments from check on assignment of scalars to unassigned
    arrays and correct wrong code within the corresponding block.

2015-01-25  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/69385
    * gfortran.dg/allocate_error_6.f90: New test.

[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 3073 bytes --]

Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c	(revision 232800)
--- gcc/fortran/trans-expr.c	(working copy)
*************** gfc_trans_assignment_1 (gfc_expr * expr1
*** 9286,9291 ****
--- 9286,9292 ----
      {
        gfc_conv_expr (&lse, expr1);
        if (gfc_option.rtcheck & GFC_RTCHECK_MEM
+ 	  && !init_flag
  	  && gfc_expr_attr (expr1).allocatable
  	  && expr1->rank
  	  && !expr2->rank)
*************** gfc_trans_assignment_1 (gfc_expr * expr1
*** 9293,9306 ****
  	  tree cond;
  	  const char* msg;
  
! 	  tmp = expr1->symtree->n.sym->backend_decl;
! 	  if (POINTER_TYPE_P (TREE_TYPE (tmp)))
! 	    tmp = build_fold_indirect_ref_loc (input_location, tmp);
  
! 	  if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp)))
! 	    tmp = gfc_conv_descriptor_data_get (tmp);
! 	  else
! 	    tmp = TREE_OPERAND (lse.expr, 0);
  
  	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
  				  tmp, build_int_cst (TREE_TYPE (tmp), 0));
--- 9294,9310 ----
  	  tree cond;
  	  const char* msg;
  
! 	  /* We should only get array references here.  */
! 	  gcc_assert (TREE_CODE (lse.expr) == POINTER_PLUS_EXPR
! 		      || TREE_CODE (lse.expr) == ARRAY_REF);
  
! 	  /* 'tmp' is either the pointer to the array(POINTER_PLUS_EXPR)
! 	     or the array itself(ARRAY_REF).  */
! 	  tmp = TREE_OPERAND (lse.expr, 0);
! 
! 	  /* Provide the address of the array.  */
! 	  if (TREE_CODE (lse.expr) == ARRAY_REF)
! 	    tmp = gfc_build_addr_expr (NULL_TREE, tmp);
  
  	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
  				  tmp, build_int_cst (TREE_TYPE (tmp), 0));
Index: gcc/testsuite/gfortran.dg/allocate_error_6.f90
===================================================================
*** gcc/testsuite/gfortran.dg/allocate_error_6.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/allocate_error_6.f90	(working copy)
***************
*** 0 ****
--- 1,40 ----
+ ! { dg-do run }
+ ! { dg-additional-options "-fcheck=mem" }
+ ! { dg-shouldfail "Fortran runtime error: Assignment of scalar to unallocated array" }
+ !
+ ! This omission was encountered in the course of fixing PR54070. Whilst this is a
+ ! very specific case, others such as allocatable components have been tested.
+ !
+ ! Contributed by Tobias Burnus  <burnus@gcc.gnu.org>
+ !
+ function g(a) result (res)
+   real :: a
+   real,allocatable :: res(:)
+   res = a  ! Since 'res' is not allocated, a runtime error should occur.
+ end function
+ 
+   interface
+     function g(a) result(res)
+       real :: a
+       real,allocatable :: res(:)
+     end function
+   end interface
+ !  print *, g(2.0)
+ !  call foo
+   call foofoo
+ contains
+   subroutine foo
+     type bar
+       real, allocatable, dimension(:) :: r
+     end type
+     type (bar) :: foobar
+     foobar%r = 1.0
+   end subroutine
+   subroutine foofoo
+     type barfoo
+       character(:), allocatable, dimension(:) :: c
+     end type
+     type (barfoo) :: foobarfoo
+     foobarfoo%c = "1.0"
+   end subroutine
+ end

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

* Re: [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem
  2016-01-25 21:03 [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem Paul Richard Thomas
@ 2016-01-25 21:13 ` Janus Weil
  2016-01-26  9:02   ` Paul Richard Thomas
  2016-01-26 21:59   ` Paul Richard Thomas
  0 siblings, 2 replies; 4+ messages in thread
From: Janus Weil @ 2016-01-25 21:13 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

Hi Paul,

seems we were pretty well-synchronized in posting this (in the PR it
sounded as if you wanted me to submit it ...)

In any case, the patch is ok for my taste.

Thanks!

Cheers,
Janus



2016-01-25 22:02 GMT+01:00 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
> Dear All,
>
> The initial report concerns initialization assignments that should be
> excluded from the check for assignment of scalars to unallocated
> arrays. This part is so trivial that it does not require a test. On
> the other hand, the block that implemented the check was plain and
> simple wrong and the rest of the patch corrects this. It is commented
> such as to be fully comprehensible.
>
> Bootstrapped and regtested on FC21/x86_64 - OK for trunk and for
> 5-branch when all the wrinkles (PR69422 and 69423) are sorted out?
>
> Cheers
>
> Paul
>
> 2016-01-25  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/69385
>     * trans-expr.c (gfc_trans_assignment_1): Exclude initialization
>     assignments from check on assignment of scalars to unassigned
>     arrays and correct wrong code within the corresponding block.
>
> 2015-01-25  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/69385
>     * gfortran.dg/allocate_error_6.f90: New test.

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

* Re: [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem
  2016-01-25 21:13 ` Janus Weil
@ 2016-01-26  9:02   ` Paul Richard Thomas
  2016-01-26 21:59   ` Paul Richard Thomas
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2016-01-26  9:02 UTC (permalink / raw)
  To: Janus Weil; +Cc: fortran, gcc-patches

Hi Janus,

Thanks!

In fact I was asking you if you would submit/commit in advance of my
return :-) I'll do the business tonight.

Cheers

Paul

On 25 January 2016 at 22:13, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi Paul,
>
> seems we were pretty well-synchronized in posting this (in the PR it
> sounded as if you wanted me to submit it ...)
>
> In any case, the patch is ok for my taste.
>
> Thanks!
>
> Cheers,
> Janus
>
>
>
> 2016-01-25 22:02 GMT+01:00 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
>> Dear All,
>>
>> The initial report concerns initialization assignments that should be
>> excluded from the check for assignment of scalars to unallocated
>> arrays. This part is so trivial that it does not require a test. On
>> the other hand, the block that implemented the check was plain and
>> simple wrong and the rest of the patch corrects this. It is commented
>> such as to be fully comprehensible.
>>
>> Bootstrapped and regtested on FC21/x86_64 - OK for trunk and for
>> 5-branch when all the wrinkles (PR69422 and 69423) are sorted out?
>>
>> Cheers
>>
>> Paul
>>
>> 2016-01-25  Paul Thomas  <pault@gcc.gnu.org>
>>
>>     PR fortran/69385
>>     * trans-expr.c (gfc_trans_assignment_1): Exclude initialization
>>     assignments from check on assignment of scalars to unassigned
>>     arrays and correct wrong code within the corresponding block.
>>
>> 2015-01-25  Paul Thomas  <pault@gcc.gnu.org>
>>
>>     PR fortran/69385
>>     * gfortran.dg/allocate_error_6.f90: New test.



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein

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

* Re: [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem
  2016-01-25 21:13 ` Janus Weil
  2016-01-26  9:02   ` Paul Richard Thomas
@ 2016-01-26 21:59   ` Paul Richard Thomas
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2016-01-26 21:59 UTC (permalink / raw)
  To: Janus Weil; +Cc: fortran, gcc-patches

Dear Janus,

Thanks - committed as revision 232850.

I hope that this signals your return - we need your help!

Paul

On 25 January 2016 at 22:13, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi Paul,
>
> seems we were pretty well-synchronized in posting this (in the PR it
> sounded as if you wanted me to submit it ...)
>
> In any case, the patch is ok for my taste.
>
> Thanks!
>
> Cheers,
> Janus
>
>
>
> 2016-01-25 22:02 GMT+01:00 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
>> Dear All,
>>
>> The initial report concerns initialization assignments that should be
>> excluded from the check for assignment of scalars to unallocated
>> arrays. This part is so trivial that it does not require a test. On
>> the other hand, the block that implemented the check was plain and
>> simple wrong and the rest of the patch corrects this. It is commented
>> such as to be fully comprehensible.
>>
>> Bootstrapped and regtested on FC21/x86_64 - OK for trunk and for
>> 5-branch when all the wrinkles (PR69422 and 69423) are sorted out?
>>
>> Cheers
>>
>> Paul
>>
>> 2016-01-25  Paul Thomas  <pault@gcc.gnu.org>
>>
>>     PR fortran/69385
>>     * trans-expr.c (gfc_trans_assignment_1): Exclude initialization
>>     assignments from check on assignment of scalars to unassigned
>>     arrays and correct wrong code within the corresponding block.
>>
>> 2015-01-25  Paul Thomas  <pault@gcc.gnu.org>
>>
>>     PR fortran/69385
>>     * gfortran.dg/allocate_error_6.f90: New test.



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein

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

end of thread, other threads:[~2016-01-26 21:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 21:03 [Patch, fortran] PR69385 - [6 regression] ICE on valid with -fcheck=mem Paul Richard Thomas
2016-01-25 21:13 ` Janus Weil
2016-01-26  9:02   ` Paul Richard Thomas
2016-01-26 21:59   ` Paul Richard Thomas

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).