* [patch, fortran] ICE in attr_decl1, at fortran/decl.c:8691
@ 2022-12-26 22:26 Jerry DeLisle
2022-12-27 11:04 ` Harald Anlauf
0 siblings, 1 reply; 2+ messages in thread
From: Jerry DeLisle @ 2022-12-26 22:26 UTC (permalink / raw)
To: gfortran; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
The attached patch was provided by Steve Kargl. After exploring for
possible other checks I settled on leaving the patch intact.
Two existing test cases updated as different but sensible error messages
resulted.
Regression tested on main line.
OK to commit?
Regards,
Jerry
Author: Steve Kargl <kargl@gcc.gnu.org>
Date: Mon Dec 26 14:07:04 2022 -0800
Modify checks to avoid referencing NULL pointer.
Update test cases with error messages that changed as a result.
gcc/fortran/ChangeLog:
* decl.cc (attr_decl1): Guard against NULL pointer.
* parse.cc (match_deferred_characteristics): Include
BT_CLASS in check for
derived being undefined.
gcc/testsuite/ChangeLog:
* gfortran.dg/class_result_4.f90: Update error message check.
* gfortran.dg/pr85779_3.f90: Update error message check.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr102331.diff --]
[-- Type: text/x-patch; name=pr102331.diff, Size: 2478 bytes --]
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index e593518a77e..bac7b6568b0 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -8743,7 +8743,9 @@ attr_decl1 (void)
/* Update symbol table. DIMENSION attribute is set in
gfc_set_array_spec(). For CLASS variables, this must be applied
to the first component, or '_data' field. */
- if (sym->ts.type == BT_CLASS && sym->ts.u.derived->attr.is_class)
+ if (sym->ts.type == BT_CLASS
+ && sym->ts.u.derived
+ && sym->ts.u.derived->attr.is_class)
{
/* gfc_set_array_spec sets sym->attr not CLASS_DATA(sym)->attr. Check
for duplicate attribute here. */
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index bc2b2188eea..6186c48aee2 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -3934,7 +3934,7 @@ match_deferred_characteristics (gfc_typespec * ts)
m = gfc_match_prefix (ts);
gfc_buffer_error (false);
- if (ts->type == BT_DERIVED)
+ if (ts->type == BT_DERIVED || ts->type == BT_CLASS)
{
ts->kind = 0;
@@ -4215,7 +4215,7 @@ declSt:
if (bad_characteristic)
{
ts = &gfc_current_block ()->result->ts;
- if (ts->type != BT_DERIVED)
+ if (ts->type != BT_DERIVED && ts->type != BT_CLASS)
gfc_error ("Bad kind expression for function %qs at %L",
gfc_current_block ()->name,
&gfc_current_block ()->declared_at);
diff --git a/gcc/testsuite/gfortran.dg/class_result_4.f90 b/gcc/testsuite/gfortran.dg/class_result_4.f90
index 4b22a3c30ee..5497ac652ec 100644
--- a/gcc/testsuite/gfortran.dg/class_result_4.f90
+++ b/gcc/testsuite/gfortran.dg/class_result_4.f90
@@ -1,6 +1,6 @@
! { dg-do compile }
! PR fortran/78500
-class(t) function f() ! { dg-error "must be dummy, allocatable or pointer" }
+class(t) function f() ! { dg-error "is not accessible" }
f = 1 ! { dg-error "variable must not be polymorphic" }
end
diff --git a/gcc/testsuite/gfortran.dg/pr85779_3.f90 b/gcc/testsuite/gfortran.dg/pr85779_3.f90
index fba1133b3ea..a81a9faf88e 100644
--- a/gcc/testsuite/gfortran.dg/pr85779_3.f90
+++ b/gcc/testsuite/gfortran.dg/pr85779_3.f90
@@ -1,6 +1,6 @@
! { dg-do compile }
! PR fortran/85779
-class(t) function f() ! { dg-error "must be dummy, allocatable or pointer" }
+class(t) function f() ! { dg-error "is not accessible" }
type f ! { dg-error "already has a basic type" }
end type ! { dg-error "END FUNCTION statement" }
end
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch, fortran] ICE in attr_decl1, at fortran/decl.c:8691
2022-12-26 22:26 [patch, fortran] ICE in attr_decl1, at fortran/decl.c:8691 Jerry DeLisle
@ 2022-12-27 11:04 ` Harald Anlauf
0 siblings, 0 replies; 2+ messages in thread
From: Harald Anlauf @ 2022-12-27 11:04 UTC (permalink / raw)
To: Jerry DeLisle, gfortran; +Cc: gcc-patches
Hi Jerry,
Am 26.12.22 um 23:26 schrieb Jerry DeLisle via Gcc-patches:
> The attached patch was provided by Steve Kargl. After exploring for
> possible other checks I settled on leaving the patch intact.
>
> Two existing test cases updated as different but sensible error messages
> resulted.
I think this is fine. The error message for CLASS is
now arguably more consistent with TYPE.
> Regression tested on main line.
>
> OK to commit?
Regarding the format of the commit message: if you want
bugzilla to get updated properly, please consider adding
PR/fortran ###### to the respective parts below.
It is also custom to have a one-line summary including
e.g. [PR######] to make it easier for others to relate
a commit to bugzilla.
OK with these things fixed.
Thanks for taking this!
Harald
> Regards,
>
> Jerry
>
> Author: Steve Kargl <kargl@gcc.gnu.org>
> Date: Mon Dec 26 14:07:04 2022 -0800
>
> Modify checks to avoid referencing NULL pointer.
> Update test cases with error messages that changed as a result.
>
> gcc/fortran/ChangeLog:
>
> * decl.cc (attr_decl1): Guard against NULL pointer.
> * parse.cc (match_deferred_characteristics): Include
> BT_CLASS in check for
> derived being undefined.
>
> gcc/testsuite/ChangeLog:
>
> * gfortran.dg/class_result_4.f90: Update error message check.
> * gfortran.dg/pr85779_3.f90: Update error message check.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-27 11:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-26 22:26 [patch, fortran] ICE in attr_decl1, at fortran/decl.c:8691 Jerry DeLisle
2022-12-27 11: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).