* [PATCH fortran/95342] - [9/10/11 Regression] ICE in gfc_match_subroutine, at fortran/decl.c:7913
@ 2020-11-26 21:25 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2020-11-26 21:25 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 755 bytes --]
Dear all,
two almost obvious, trivial issues issues with NULL pointer dereferences.
Steve found the locations, but his solution changes the error messages
as compared to 7/8. I've chosen the conservative way which keeps the
documented intent of the source code.
Regtested on x86_64-pc-linux-gnu.
OK for master? Backport to affected 10- and 9-branches?
(8.4.1 was/is fine).
Thanks,
Harald
PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913
Add checks for NULL pointers before dereferencing them.
gcc/fortran/ChangeLog:
PR fortran/95342
* decl.c (gfc_match_function_decl): Avoid NULL pointer dereference.
(gfc_match_subroutine): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/95342
* gfortran.dg/pr95342.f90: New test.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr95342.patch --]
[-- Type: text/x-patch, Size: 1635 bytes --]
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 93a155c5f75..c85ae0de952 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -7408,6 +7408,7 @@ gfc_match_function_decl (void)
procedure interface body. */
if (sym->attr.is_bind_c && sym->attr.module_procedure && sym->old_symbol
&& strcmp (sym->name, sym->old_symbol->name) == 0
+ && sym->binding_label && sym->old_symbol->binding_label
&& strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0)
{
const char *null = "NULL", *s1, *s2;
@@ -7923,6 +7924,7 @@ gfc_match_subroutine (void)
procedure interface body. */
if (sym->attr.module_procedure && sym->old_symbol
&& strcmp (sym->name, sym->old_symbol->name) == 0
+ && sym->binding_label && sym->old_symbol->binding_label
&& strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0)
{
const char *null = "NULL", *s1, *s2;
diff --git a/gcc/testsuite/gfortran.dg/pr95342.f90 b/gcc/testsuite/gfortran.dg/pr95342.f90
new file mode 100644
index 00000000000..41c987d3bbb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95342.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913
+
+module m1
+ interface
+ module subroutine s()
+ end
+ subroutine s() bind(c) ! { dg-error "EXTERNAL attribute conflicts" }
+ end ! { dg-error "END INTERFACE" }
+ end interface
+end
+
+module m2
+ interface
+ module function f()
+ end
+ function f() bind(c)
+ end ! { dg-error "Duplicate EXTERNAL attribute" }
+ end interface
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-26 21:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 21:25 [PATCH fortran/95342] - [9/10/11 Regression] ICE in gfc_match_subroutine, at fortran/decl.c:7913 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).