fortran/intrinsic.texi: Add 'passed by value' to signal handler

Message ID a663b83c-356a-410c-871b-1897d12fd76a@codesourcery.com
State Accepted
Headers
Series fortran/intrinsic.texi: Add 'passed by value' to signal handler |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Tobias Burnus Oct. 16, 2023, 5:11 p.m. UTC
  Yesterday, someone was confused because the signal handler did not work.

It turned out that the created Fortran procedure used as handler used
pass by reference - and 'signal' passed the it by value.

This patch adds the 'passed by value' to the wording:

"@var{HANDLER} to be executed with a single integer argument passed by
value"

OK for mainline?

Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Comments

Harald Anlauf Oct. 16, 2023, 6:31 p.m. UTC | #1
Hi Tobias,

Am 16.10.23 um 19:11 schrieb Tobias Burnus:
> Yesterday, someone was confused because the signal handler did not work.
> 
> It turned out that the created Fortran procedure used as handler used
> pass by reference - and 'signal' passed the it by value.
> 
> This patch adds the 'passed by value' to the wording:
> 
> "@var{HANDLER} to be executed with a single integer argument passed by
> value"
> 
> OK for mainline?

I think the patch qualifies as obvious.

While at it, you might consider removing the comment a few lines below
the place you are changing,

@c TODO: What should the interface of the handler be?  Does it take 
arguments?

and enhance the given example by e.g.:

subroutine handler_print (signal_number)
   integer, value :: signal_number
   print *, "In handler_print: received signal number", signal_number
end subroutine handler_print

Thanks,
Harald

> Tobias
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 
> 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: 
> Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; 
> Registergericht München, HRB 106955
  
Steve Kargl Oct. 16, 2023, 6:37 p.m. UTC | #2
On Mon, Oct 16, 2023 at 08:31:20PM +0200, Harald Anlauf wrote:
> 
> Am 16.10.23 um 19:11 schrieb Tobias Burnus:
> > Yesterday, someone was confused because the signal handler did not work.
> > 
> > It turned out that the created Fortran procedure used as handler used
> > pass by reference - and 'signal' passed the it by value.
> > 
> > This patch adds the 'passed by value' to the wording:
> > 
> > "@var{HANDLER} to be executed with a single integer argument passed by
> > value"
> > 
> > OK for mainline?
> 
> I think the patch qualifies as obvious.
> 
> While at it, you might consider removing the comment a few lines below
> the place you are changing,
> 
> @c TODO: What should the interface of the handler be?  Does it take
> arguments?
> 
> and enhance the given example by e.g.:
> 
> subroutine handler_print (signal_number)
>   integer, value :: signal_number
>   print *, "In handler_print: received signal number", signal_number
> end subroutine handler_print
> 

Good suggestion, Harald.  I was composing a similar email
when I saw yours pop into by inbox.
  

Patch

fortran/intrinsic.texi: Add 'passed by value' to signal handler

gcc/fortran/ChangeLog:

	* intrinsic.texi (signal): Mention that the argument
	passed to the signal handler procedure is passed by reference.

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 6c7ad03a02c..3620209e00a 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -13168,10 +13168,10 @@  end program test_sign
 @table @asis
 @item @emph{Description}:
 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
-@var{HANDLER} to be executed with a single integer argument when signal
-@var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
-turn off handling of signal @var{NUMBER} or revert to its default
-action.  See @code{signal(2)}.
+@var{HANDLER} to be executed with a single integer argument passed by
+value when signal @var{NUMBER} occurs.  If @var{HANDLER} is an integer,
+it can be used to turn off handling of signal @var{NUMBER} or revert to
+its default action.  See @code{signal(2)}.
 
 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
 is supplied, it is set to the value returned by @code{signal(2)}.