public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* PDT type parameters are not restricted to default integer
@ 2021-10-22 19:35 Steve Kargl
  2021-10-22 20:16 ` Harald Anlauf
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2021-10-22 19:35 UTC (permalink / raw)
  To: fortran

Here's an obvious quick fix.  Please apply.


diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 6043e100fbb..e889bb44142 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5619,14 +5619,6 @@ match_attr_spec (void)
 		  m = MATCH_ERROR;
 		  goto cleanup;
 		}
-	      if (current_ts.kind != gfc_default_integer_kind)
-		{
-		  gfc_error ("Component with LEN attribute at %C must be "
-			     "default integer kind (%d)",
-			      gfc_default_integer_kind);
-		  m = MATCH_ERROR;
-		  goto cleanup;
-		}
 	    }
 	  else
 	    {
-- 
Steve

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

* Re: PDT type parameters are not restricted to default integer
  2021-10-22 19:35 PDT type parameters are not restricted to default integer Steve Kargl
@ 2021-10-22 20:16 ` Harald Anlauf
  2021-10-22 20:16   ` Harald Anlauf
  2021-10-22 20:25   ` Steve Kargl
  0 siblings, 2 replies; 8+ messages in thread
From: Harald Anlauf @ 2021-10-22 20:16 UTC (permalink / raw)
  To: fortran

Hi Steve,

Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
> Here's an obvious quick fix.  Please apply.
> 
> 
> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> index 6043e100fbb..e889bb44142 100644
> --- a/gcc/fortran/decl.c
> +++ b/gcc/fortran/decl.c
> @@ -5619,14 +5619,6 @@ match_attr_spec (void)
>   		  m = MATCH_ERROR;
>   		  goto cleanup;
>   		}
> -	      if (current_ts.kind != gfc_default_integer_kind)
> -		{
> -		  gfc_error ("Component with LEN attribute at %C must be "
> -			     "default integer kind (%d)",
> -			      gfc_default_integer_kind);
> -		  m = MATCH_ERROR;
> -		  goto cleanup;
> -		}
>   	    }
>   	  else
>   	    {
> 

I think you are right.  We should always have allowed any integer kind.

However, have you checked whether this change introduces regressions?
If you don't, somebody else will.  Please open a PR, then.

Harald


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

* Re: PDT type parameters are not restricted to default integer
  2021-10-22 20:16 ` Harald Anlauf
@ 2021-10-22 20:16   ` Harald Anlauf
  2021-10-22 20:25   ` Steve Kargl
  1 sibling, 0 replies; 8+ messages in thread
From: Harald Anlauf @ 2021-10-22 20:16 UTC (permalink / raw)
  To: Steve Kargl, fortran

Hi Steve,

Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
> Here's an obvious quick fix.  Please apply.
>
>
> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> index 6043e100fbb..e889bb44142 100644
> --- a/gcc/fortran/decl.c
> +++ b/gcc/fortran/decl.c
> @@ -5619,14 +5619,6 @@ match_attr_spec (void)
>   		  m = MATCH_ERROR;
>   		  goto cleanup;
>   		}
> -	      if (current_ts.kind != gfc_default_integer_kind)
> -		{
> -		  gfc_error ("Component with LEN attribute at %C must be "
> -			     "default integer kind (%d)",
> -			      gfc_default_integer_kind);
> -		  m = MATCH_ERROR;
> -		  goto cleanup;
> -		}
>   	    }
>   	  else
>   	    {
>

I think you are right.  We should always have allowed any integer kind.

However, have you checked whether this change introduces regressions?
If you don't, somebody else will.  Please open a PR, then.

Harald

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

* Re: PDT type parameters are not restricted to default integer
  2021-10-22 20:16 ` Harald Anlauf
  2021-10-22 20:16   ` Harald Anlauf
@ 2021-10-22 20:25   ` Steve Kargl
  2021-10-24 19:00     ` [PATCH] PR fortran/102917 - " Harald Anlauf
  1 sibling, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2021-10-22 20:25 UTC (permalink / raw)
  To: Harald Anlauf; +Cc: fortran

On Fri, Oct 22, 2021 at 10:16:05PM +0200, Harald Anlauf wrote:
> Hi Steve,
> 
> Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
> > Here's an obvious quick fix.  Please apply.
> > 
> > 
> > diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> > index 6043e100fbb..e889bb44142 100644
> > --- a/gcc/fortran/decl.c
> > +++ b/gcc/fortran/decl.c
> > @@ -5619,14 +5619,6 @@ match_attr_spec (void)
> >   		  m = MATCH_ERROR;
> >   		  goto cleanup;
> >   		}
> > -	      if (current_ts.kind != gfc_default_integer_kind)
> > -		{
> > -		  gfc_error ("Component with LEN attribute at %C must be "
> > -			     "default integer kind (%d)",
> > -			      gfc_default_integer_kind);
> > -		  m = MATCH_ERROR;
> > -		  goto cleanup;
> > -		}
> >   	    }
> >   	  else
> >   	    {
> 
> I think you are right.  We should always have allowed any integer kind.
> 
> However, have you checked whether this change introduces regressions?
> If you don't, somebody else will.  Please open a PR, then.
> 

It seems that pdt_4.f03 will fail with the above patch because
it explicitly tests for this error message.  That's the only
failure in the testsuite.  For the record, F2003, page 48,

   R435 type-param-def-stmt  is INTEGER [ kind-selector ] , ...

   Each type parameter is itself of type integer.  If its kind selector
   is omitted, the kind type parameter is default integer.

Now that I think about and look, there is a nearby similar gcc_error()
for KIND.  This should be removed too.

-- 
Steve

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

* [PATCH] PR fortran/102917 - PDT type parameters are not restricted to default integer
  2021-10-22 20:25   ` Steve Kargl
@ 2021-10-24 19:00     ` Harald Anlauf
  2021-10-24 19:04       ` Steve Kargl
  2021-10-26  9:55       ` Tobias Burnus
  0 siblings, 2 replies; 8+ messages in thread
From: Harald Anlauf @ 2021-10-24 19:00 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

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

Dear Fortranners, Steve,

I've created PR 102917 for tracking this issue and packaged
the attached patch.

Regtested on x86_64-pc-linux-gnu.  OK mainline?

Thanks,
Harald

> Gesendet: Freitag, 22. Oktober 2021 um 22:25 Uhr
> Von: "Steve Kargl" <sgk@troutmask.apl.washington.edu>
> An: "Harald Anlauf" <anlauf@gmx.de>
> Cc: fortran@gcc.gnu.org
> Betreff: Re: PDT type parameters are not restricted to default integer
>
> On Fri, Oct 22, 2021 at 10:16:05PM +0200, Harald Anlauf wrote:
> > Hi Steve,
> >
> > Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
> > > Here's an obvious quick fix.  Please apply.
> > >
> > >
> > > diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> > > index 6043e100fbb..e889bb44142 100644
> > > --- a/gcc/fortran/decl.c
> > > +++ b/gcc/fortran/decl.c
> > > @@ -5619,14 +5619,6 @@ match_attr_spec (void)
> > >   		  m = MATCH_ERROR;
> > >   		  goto cleanup;
> > >   		}
> > > -	      if (current_ts.kind != gfc_default_integer_kind)
> > > -		{
> > > -		  gfc_error ("Component with LEN attribute at %C must be "
> > > -			     "default integer kind (%d)",
> > > -			      gfc_default_integer_kind);
> > > -		  m = MATCH_ERROR;
> > > -		  goto cleanup;
> > > -		}
> > >   	    }
> > >   	  else
> > >   	    {
> >
> > I think you are right.  We should always have allowed any integer kind.
> >
> > However, have you checked whether this change introduces regressions?
> > If you don't, somebody else will.  Please open a PR, then.
> >
>
> It seems that pdt_4.f03 will fail with the above patch because
> it explicitly tests for this error message.  That's the only
> failure in the testsuite.  For the record, F2003, page 48,
>
>    R435 type-param-def-stmt  is INTEGER [ kind-selector ] , ...
>
>    Each type parameter is itself of type integer.  If its kind selector
>    is omitted, the kind type parameter is default integer.
>
> Now that I think about and look, there is a nearby similar gcc_error()
> for KIND.  This should be removed too.
>
> --
> Steve
>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr102917.diff --]
[-- Type: text/x-patch, Size: 1940 bytes --]

Fortran: do not restrict PDT KIND and LEN type parameters to default integer

gcc/fortran/ChangeLog:

	PR fortran/102917
	* decl.c (match_attr_spec): Remove invalid integer kind checks on
	KIND and LEN attributes of PDTs.

gcc/testsuite/ChangeLog:

	PR fortran/102917
	* gfortran.dg/pdt_4.f03: Adjust testcase.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 6043e100fbb..ce61e53eb7b 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5592,14 +5592,6 @@ match_attr_spec (void)
 		  m = MATCH_ERROR;
 		  goto cleanup;
 		}
-	      if (current_ts.kind != gfc_default_integer_kind)
-		{
-		  gfc_error ("Component with KIND attribute at %C must be "
-			     "default integer kind (%d)",
-			      gfc_default_integer_kind);
-		  m = MATCH_ERROR;
-		  goto cleanup;
-		}
 	    }
 	  else if (d == DECL_LEN)
 	    {
@@ -5619,14 +5611,6 @@ match_attr_spec (void)
 		  m = MATCH_ERROR;
 		  goto cleanup;
 		}
-	      if (current_ts.kind != gfc_default_integer_kind)
-		{
-		  gfc_error ("Component with LEN attribute at %C must be "
-			     "default integer kind (%d)",
-			      gfc_default_integer_kind);
-		  m = MATCH_ERROR;
-		  goto cleanup;
-		}
 	    }
 	  else
 	    {
diff --git a/gcc/testsuite/gfortran.dg/pdt_4.f03 b/gcc/testsuite/gfortran.dg/pdt_4.f03
index c1af65a5248..37412e4ca82 100644
--- a/gcc/testsuite/gfortran.dg/pdt_4.f03
+++ b/gcc/testsuite/gfortran.dg/pdt_4.f03
@@ -28,9 +28,9 @@ end module

   type :: bad_pdt (a,b, c, d)  ! { dg-error "does not have a component" }
     real, kind :: a            ! { dg-error "must be INTEGER" }
-    INTEGER(8), kind :: b      ! { dg-error "be default integer kind" }
+    INTEGER(8), kind :: b
     real, LEN :: c             ! { dg-error "must be INTEGER" }
-    INTEGER(8), LEN :: d       ! { dg-error "be default integer kind" }
+    INTEGER(8), LEN :: d
   end type

   type :: mytype (a,b)

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

* Re: [PATCH] PR fortran/102917 - PDT type parameters are not restricted to default integer
  2021-10-24 19:00     ` [PATCH] PR fortran/102917 - " Harald Anlauf
@ 2021-10-24 19:04       ` Steve Kargl
  2021-10-26  9:55       ` Tobias Burnus
  1 sibling, 0 replies; 8+ messages in thread
From: Steve Kargl @ 2021-10-24 19:04 UTC (permalink / raw)
  To: Harald Anlauf; +Cc: fortran, gcc-patches

On Sun, Oct 24, 2021 at 09:00:52PM +0200, Harald Anlauf wrote:
> Dear Fortranners, Steve,
> 
> I've created PR 102917 for tracking this issue and packaged
> the attached patch.
> 
> Regtested on x86_64-pc-linux-gnu.  OK mainline?
> 

Thanks for picking this up.  The patch looks good to me, 
but you may want to have Thomas or Tobias cast a quick
glance over it.

-- 
Steve

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

* Re: [PATCH] PR fortran/102917 - PDT type parameters are not restricted to default integer
  2021-10-24 19:00     ` [PATCH] PR fortran/102917 - " Harald Anlauf
  2021-10-24 19:04       ` Steve Kargl
@ 2021-10-26  9:55       ` Tobias Burnus
  2021-10-26 12:04         ` Harald Anlauf
  1 sibling, 1 reply; 8+ messages in thread
From: Tobias Burnus @ 2021-10-26  9:55 UTC (permalink / raw)
  To: Harald Anlauf, Steve Kargl; +Cc: gcc-patches, fortran

Dear Harald, dear all,

On 24.10.21 21:00, Harald Anlauf via Fortran wrote:
> I've created PR 102917 for tracking this issue and packaged
> the attached patch.
>
> Regtested on x86_64-pc-linux-gnu.  OK mainline?

OK. I wonder whether a valid len/kind example should be added which uses
such a PDT with non-default-kind integer.

Tobias

>> Gesendet: Freitag, 22. Oktober 2021 um 22:25 Uhr
>> Von: "Steve Kargl" <sgk@troutmask.apl.washington.edu>
>> An: "Harald Anlauf" <anlauf@gmx.de>
>> Cc: fortran@gcc.gnu.org
>> Betreff: Re: PDT type parameters are not restricted to default integer
>>
>> On Fri, Oct 22, 2021 at 10:16:05PM +0200, Harald Anlauf wrote:
>>> Hi Steve,
>>>
>>> Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
>>>> Here's an obvious quick fix.  Please apply.
>>>>
>>>>
>>>> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
>>>> index 6043e100fbb..e889bb44142 100644
>>>> --- a/gcc/fortran/decl.c
>>>> +++ b/gcc/fortran/decl.c
>>>> @@ -5619,14 +5619,6 @@ match_attr_spec (void)
>>>>                      m = MATCH_ERROR;
>>>>                      goto cleanup;
>>>>                    }
>>>> -        if (current_ts.kind != gfc_default_integer_kind)
>>>> -          {
>>>> -            gfc_error ("Component with LEN attribute at %C must be "
>>>> -                       "default integer kind (%d)",
>>>> -                        gfc_default_integer_kind);
>>>> -            m = MATCH_ERROR;
>>>> -            goto cleanup;
>>>> -          }
>>>>                }
>>>>              else
>>>>                {
>>> I think you are right.  We should always have allowed any integer kind.
>>>
>>> However, have you checked whether this change introduces regressions?
>>> If you don't, somebody else will.  Please open a PR, then.
>>>
>> It seems that pdt_4.f03 will fail with the above patch because
>> it explicitly tests for this error message.  That's the only
>> failure in the testsuite.  For the record, F2003, page 48,
>>
>>     R435 type-param-def-stmt  is INTEGER [ kind-selector ] , ...
>>
>>     Each type parameter is itself of type integer.  If its kind selector
>>     is omitted, the kind type parameter is default integer.
>>
>> Now that I think about and look, there is a nearby similar gcc_error()
>> for KIND.  This should be removed too.
>>
>> --
>> Steve
>>
-----------------
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

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

* Re: [PATCH] PR fortran/102917 - PDT type parameters are not restricted to default integer
  2021-10-26  9:55       ` Tobias Burnus
@ 2021-10-26 12:04         ` Harald Anlauf
  0 siblings, 0 replies; 8+ messages in thread
From: Harald Anlauf @ 2021-10-26 12:04 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: Steve Kargl, gcc-patches, fortran

Hi Tobias,

> OK. I wonder whether a valid len/kind example should be added which uses
> such a PDT with non-default-kind integer.

the testcase pdt_4.f03 did actually check for the error message that gets
removed and had to be adjusted.  Removing just the dg-error does that job :-)

Thanks,
Harald

> Tobias
> 
> >> Gesendet: Freitag, 22. Oktober 2021 um 22:25 Uhr
> >> Von: "Steve Kargl" <sgk@troutmask.apl.washington.edu>
> >> An: "Harald Anlauf" <anlauf@gmx.de>
> >> Cc: fortran@gcc.gnu.org
> >> Betreff: Re: PDT type parameters are not restricted to default integer
> >>
> >> On Fri, Oct 22, 2021 at 10:16:05PM +0200, Harald Anlauf wrote:
> >>> Hi Steve,
> >>>
> >>> Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran:
> >>>> Here's an obvious quick fix.  Please apply.
> >>>>
> >>>>
> >>>> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> >>>> index 6043e100fbb..e889bb44142 100644
> >>>> --- a/gcc/fortran/decl.c
> >>>> +++ b/gcc/fortran/decl.c
> >>>> @@ -5619,14 +5619,6 @@ match_attr_spec (void)
> >>>>                      m = MATCH_ERROR;
> >>>>                      goto cleanup;
> >>>>                    }
> >>>> -        if (current_ts.kind != gfc_default_integer_kind)
> >>>> -          {
> >>>> -            gfc_error ("Component with LEN attribute at %C must be "
> >>>> -                       "default integer kind (%d)",
> >>>> -                        gfc_default_integer_kind);
> >>>> -            m = MATCH_ERROR;
> >>>> -            goto cleanup;
> >>>> -          }
> >>>>                }
> >>>>              else
> >>>>                {
> >>> I think you are right.  We should always have allowed any integer kind.
> >>>
> >>> However, have you checked whether this change introduces regressions?
> >>> If you don't, somebody else will.  Please open a PR, then.
> >>>
> >> It seems that pdt_4.f03 will fail with the above patch because
> >> it explicitly tests for this error message.  That's the only
> >> failure in the testsuite.  For the record, F2003, page 48,
> >>
> >>     R435 type-param-def-stmt  is INTEGER [ kind-selector ] , ...
> >>
> >>     Each type parameter is itself of type integer.  If its kind selector
> >>     is omitted, the kind type parameter is default integer.
> >>
> >> Now that I think about and look, there is a nearby similar gcc_error()
> >> for KIND.  This should be removed too.
> >>
> >> --
> >> Steve
> >>
> -----------------
> 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
>

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 19:35 PDT type parameters are not restricted to default integer Steve Kargl
2021-10-22 20:16 ` Harald Anlauf
2021-10-22 20:16   ` Harald Anlauf
2021-10-22 20:25   ` Steve Kargl
2021-10-24 19:00     ` [PATCH] PR fortran/102917 - " Harald Anlauf
2021-10-24 19:04       ` Steve Kargl
2021-10-26  9:55       ` Tobias Burnus
2021-10-26 12:04         ` Harald Anlauf

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