* [PATCH] fortran/66052 -- Prevent dereference of NULL pointer
@ 2015-05-15 15:23 Steve Kargl
2015-05-16 13:46 ` Mikael Morin
0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2015-05-15 15:23 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 326 bytes --]
Regression tested on trunk. OK to commit?
Subject says it all.
2015-05-XX Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66052
* decl.c(gfc_match_protected): Prevent dereference of NULL pointer.
2015-05-XX Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66052
* gfortran.dg/protected_9.f90: New test.
--
Steve
[-- Attachment #2: pr66052.diff --]
[-- Type: text/x-diff, Size: 1135 bytes --]
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 223094)
+++ gcc/fortran/decl.c (working copy)
@@ -6968,7 +6968,8 @@ gfc_match_protected (void)
gfc_symbol *sym;
match m;
- if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
+ if (gfc_current_ns->proc_name
+ && gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
{
gfc_error ("PROTECTED at %C only allowed in specification "
"part of a module");
Index: gcc/testsuite/gfortran.dg/protected_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/protected_9.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/protected_9.f90 (working copy)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! PR fortran/66052
+!
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+module a
+ contains
+ protected x ! { dg-error "Unexpected attribute declaration statement" }
+end module a
+
+program p
+ contains
+ protected x ! { dg-error "Unexpected attribute declaration statement" }
+end
+
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fortran/66052 -- Prevent dereference of NULL pointer
2015-05-15 15:23 [PATCH] fortran/66052 -- Prevent dereference of NULL pointer Steve Kargl
@ 2015-05-16 13:46 ` Mikael Morin
2015-05-18 23:00 ` Steve Kargl
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Morin @ 2015-05-16 13:46 UTC (permalink / raw)
To: Steve Kargl, fortran, gcc-patches
Le 15/05/2015 17:19, Steve Kargl a écrit :
> Regression tested on trunk. OK to commit?
>
Hello,
> Index: gcc/fortran/decl.c
> ===================================================================
> --- gcc/fortran/decl.c (revision 223094)
> +++ gcc/fortran/decl.c (working copy)
> @@ -6968,7 +6968,8 @@ gfc_match_protected (void)
> gfc_symbol *sym;
> match m;
>
> - if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
> + if (gfc_current_ns->proc_name
> + && gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
> {
> gfc_error ("PROTECTED at %C only allowed in specification "
> "part of a module");
Wouldn't one get a slightly better error message if using
!gfc_current_ns->proc_name
|| gfc_current_ns->proc_name->attr.flavor != FL_MODULE
as condition ?
OK with that change. Thanks.
Mikael
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fortran/66052 -- Prevent dereference of NULL pointer
2015-05-16 13:46 ` Mikael Morin
@ 2015-05-18 23:00 ` Steve Kargl
0 siblings, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2015-05-18 23:00 UTC (permalink / raw)
To: Mikael Morin; +Cc: fortran, gcc-patches
On Sat, May 16, 2015 at 01:58:30PM +0200, Mikael Morin wrote:
> > Index: gcc/fortran/decl.c
> > ===================================================================
> > --- gcc/fortran/decl.c (revision 223094)
> > +++ gcc/fortran/decl.c (working copy)
> > @@ -6968,7 +6968,8 @@ gfc_match_protected (void)
> > gfc_symbol *sym;
> > match m;
> >
> > - if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
> > + if (gfc_current_ns->proc_name
> > + && gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
> > {
> > gfc_error ("PROTECTED at %C only allowed in specification "
> > "part of a module");
>
> Wouldn't one get a slightly better error message if using
> !gfc_current_ns->proc_name
> || gfc_current_ns->proc_name->attr.flavor != FL_MODULE
> as condition ?
>
> OK with that change. Thanks.
>
Committed ar r223324 with your suggested change. Indeed,
a better error messaage emitted.
--
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-18 22:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 15:23 [PATCH] fortran/66052 -- Prevent dereference of NULL pointer Steve Kargl
2015-05-16 13:46 ` Mikael Morin
2015-05-18 23:00 ` Steve Kargl
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).