public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691
@ 2021-09-14 17:29 gscfq@t-online.de
2021-09-14 17:29 ` [Bug fortran/102331] " gscfq@t-online.de
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: gscfq@t-online.de @ 2021-09-14 17:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
Bug ID: 102331
Summary: ICE in attr_decl1, at fortran/decl.c:8691
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Affects versions down to at least r5 (type t not defined) :
$ cat z1.f90
class(t) function f()
allocatable :: f
end
$ cat z2.f90
class(t) function f()
pointer :: f
end
$ gfortran-12-20210905 -c z1.f90
f951: internal compiler error: Segmentation fault
0xeace0f crash_signal
../../gcc/toplev.c:328
0x7882b4 attr_decl1
../../gcc/fortran/decl.c:8691
0x7882b4 attr_decl
../../gcc/fortran/decl.c:8777
0x7f7db1 match_word
../../gcc/fortran/parse.c:65
0x7fd189 decode_statement
../../gcc/fortran/parse.c:441
0x7fda8a next_free
../../gcc/fortran/parse.c:1384
0x7fda8a next_statement
../../gcc/fortran/parse.c:1616
0x7ff2ad parse_spec
../../gcc/fortran/parse.c:4164
0x801f9c parse_progunit
../../gcc/fortran/parse.c:6114
0x803a37 gfc_parse_file()
../../gcc/fortran/parse.c:6669
0x8510ff gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
@ 2021-09-14 17:29 ` gscfq@t-online.de
2021-09-15 8:51 ` marxin at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: gscfq@t-online.de @ 2021-09-14 17:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
G. Steinmetz <gscfq@t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---
Detected with "type" instead of "class" :
$ cat za1.f90
type(t) function f()
allocatable :: f
end
$ cat za2.f90
type(t) function f()
pointer :: f
end
$ gfortran-12-20210905 -c za1.f90
za1.f90:1:0:
1 | type(t) function f()
|
Error: The type for function 'f' at (1) is not accessible
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
2021-09-14 17:29 ` [Bug fortran/102331] " gscfq@t-online.de
@ 2021-09-15 8:51 ` marxin at gcc dot gnu.org
2021-09-15 17:20 ` kargl at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-09-15 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-09-15
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
2021-09-14 17:29 ` [Bug fortran/102331] " gscfq@t-online.de
2021-09-15 8:51 ` marxin at gcc dot gnu.org
@ 2021-09-15 17:20 ` kargl at gcc dot gnu.org
2021-09-15 20:57 ` anlauf at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-09-15 17:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
The following patch fixes the problem. It has not been regression tested.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 05081c40f1e..85c95cea17f 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -8695,7 +8695,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.c b/gcc/fortran/parse.c
index 6d7845e8517..8d6d4f4e98f 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -3813,7 +3813,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;
@@ -4094,7 +4094,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);
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (2 preceding siblings ...)
2021-09-15 17:20 ` kargl at gcc dot gnu.org
@ 2021-09-15 20:57 ` anlauf at gcc dot gnu.org
2021-09-15 21:59 ` sgk at troutmask dot apl.washington.edu
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-15 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> The following patch fixes the problem. It has not been regression tested.
This restores the error, but for CLASS I now get:
pr102331.f90:2:3:
2 | allocatable :: f
| 1
Error: Unclassifiable statement at (1)
pr102331.f90:1:0:
1 | class(t) function f()
|
Error: The type for function 'f' at (1) is not accessible
while the error message for line 2 does not show up for TYPE.
Maybe there are a few more places that need fixing.
(Not only the obvious one after the second hunk for parse.c).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (3 preceding siblings ...)
2021-09-15 20:57 ` anlauf at gcc dot gnu.org
@ 2021-09-15 21:59 ` sgk at troutmask dot apl.washington.edu
2022-12-26 19:55 ` jvdelisle at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2021-09-15 21:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Sep 15, 2021 at 08:57:45PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
>
> --- Comment #3 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #2)
> > The following patch fixes the problem. It has not been regression tested.
>
> This restores the error, but for CLASS I now get:
>
> pr102331.f90:2:3:
>
> 2 | allocatable :: f
> | 1
> Error: Unclassifiable statement at (1)
> pr102331.f90:1:0:
>
> 1 | class(t) function f()
> |
> Error: The type for function 'f' at (1) is not accessible
>
> while the error message for line 2 does not show up for TYPE.
> Maybe there are a few more places that need fixing.
> (Not only the obvious one after the second hunk for parse.c).
>
Yes, likely, 'ts.type == BT_CLASS' needs to be sprinkled in
other places. Unfortunately, the 'Unclassifiable statement'
error is a last resort catch-all error. I know little about
the CLASS implementation. I suspect BT_CLASS takes a much
different path through the compiler.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (4 preceding siblings ...)
2021-09-15 21:59 ` sgk at troutmask dot apl.washington.edu
@ 2022-12-26 19:55 ` jvdelisle at gcc dot gnu.org
2022-12-26 20:14 ` jvdelisle at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-12-26 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
After exploring a while and looking for other places I have concluded that for
invalid code Steve's patch is adequate.
I will regression test it next.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (5 preceding siblings ...)
2022-12-26 19:55 ` jvdelisle at gcc dot gnu.org
@ 2022-12-26 20:14 ` jvdelisle at gcc dot gnu.org
2023-01-14 3:29 ` jvdelisle at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-12-26 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Regression testing looks good. The patch wiggles on the error messages given
for:
pr85779.f90
class_result_4.f90
In both cases they are reasonable. I don't think we need any new test cases
since we are obviously exercising the patch. If anyone insists I add the z1
and z2 cases to the testsuite, let me know and i will do so.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (6 preceding siblings ...)
2022-12-26 20:14 ` jvdelisle at gcc dot gnu.org
@ 2023-01-14 3:29 ` jvdelisle at gcc dot gnu.org
2023-01-18 1:37 ` jvdelisle at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-01-14 3:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I biffed the PR number on this commit. It should have been here. I will have
to look into amending the ChangeLog correctly.
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:cdc6bf44eec295805ae29a8aaddafd111de01c8e
commit r13-4934-gcdc6bf44eec295805ae29a8aaddafd111de01c8e
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:
PR fortran/102595
* 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:
PR fortran/102595
* gfortran.dg/class_result_4.f90: Update error message check.
* gfortran.dg/pr85779_3.f90: Update error message check.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (7 preceding siblings ...)
2023-01-14 3:29 ` jvdelisle at gcc dot gnu.org
@ 2023-01-18 1:37 ` jvdelisle at gcc dot gnu.org
2023-03-27 2:00 ` cvs-commit at gcc dot gnu.org
2023-05-29 22:06 ` kargl at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-01-18 1:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Fixed ChangeLogs PR number referenced.
commit 04d7cc165387d19e1433a4b2157d2bde7b95305b (HEAD -> master, origin/master,
origin/HEAD)
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date: Tue Jan 17 17:30:49 2023 -0800
Fix bug number reference in Changelogs
For:
gcc/fortran/ChangeLog-2022:
gcc/testsuite/ChangeLog-2022:
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (8 preceding siblings ...)
2023-01-18 1:37 ` jvdelisle at gcc dot gnu.org
@ 2023-03-27 2:00 ` cvs-commit at gcc dot gnu.org
2023-05-29 22:06 ` kargl at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-27 2:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jerry DeLisle
<jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:82ec75a726b3f8f874dacb0cb342c9bbd1233cc0
commit r12-9320-g82ec75a726b3f8f874dacb0cb342c9bbd1233cc0
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date: Sun Mar 26 18:44:35 2023 -0700
Fortran: Modify checks to avoid referencing NULL pointer.
Backport from mainline.
gcc/fortran/ChangeLog:
PR fortran/102331
* 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:
PR fortran/102331
* gfortran.dg/class_result_4.f90: Update error message check.
* gfortran.dg/pr85779_3.f90: Update error message check.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
` (9 preceding siblings ...)
2023-03-27 2:00 ` cvs-commit at gcc dot gnu.org
@ 2023-05-29 22:06 ` kargl at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-05-29 22:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #10 from kargl at gcc dot gnu.org ---
fixed on 12, 13, and master.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-29 22:06 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 17:29 [Bug fortran/102331] New: ICE in attr_decl1, at fortran/decl.c:8691 gscfq@t-online.de
2021-09-14 17:29 ` [Bug fortran/102331] " gscfq@t-online.de
2021-09-15 8:51 ` marxin at gcc dot gnu.org
2021-09-15 17:20 ` kargl at gcc dot gnu.org
2021-09-15 20:57 ` anlauf at gcc dot gnu.org
2021-09-15 21:59 ` sgk at troutmask dot apl.washington.edu
2022-12-26 19:55 ` jvdelisle at gcc dot gnu.org
2022-12-26 20:14 ` jvdelisle at gcc dot gnu.org
2023-01-14 3:29 ` jvdelisle at gcc dot gnu.org
2023-01-18 1:37 ` jvdelisle at gcc dot gnu.org
2023-03-27 2:00 ` cvs-commit at gcc dot gnu.org
2023-05-29 22:06 ` kargl at gcc dot gnu.org
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).