public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/66045 -- NULL() on RHS of assignment
@ 2015-05-15 15:19 Steve Kargl
  2015-05-16 15:12 ` FX
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-05-15 15:19 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Regression tested on trunk.  OK to commit?

The patch is self-explanatory.

Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66045
	* expr.c (gfc_check_assign):  Check for assignment of NULL() instead
	of the (intended) pointer assignment.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66045
	* gfortran.dg/null1.f90: New test.

-- 
Steve

[-- Attachment #2: pr66045.diff --]
[-- Type: text/x-diff, Size: 1805 bytes --]

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 223094)
+++ gcc/fortran/expr.c	(working copy)
@@ -3118,19 +3118,22 @@ gfc_check_assign (gfc_expr *lvalue, gfc_
 	bad_proc = true;
 
       /* (ii) The assignment is in the main program; or  */
-      if (gfc_current_ns->proc_name->attr.is_main_program)
+      if (gfc_current_ns->proc_name
+	  && gfc_current_ns->proc_name->attr.is_main_program)
 	bad_proc = true;
 
       /* (iii) A module or internal procedure...  */
-      if ((gfc_current_ns->proc_name->attr.proc == PROC_INTERNAL
-	   || gfc_current_ns->proc_name->attr.proc == PROC_MODULE)
+      if (gfc_current_ns->proc_name
+	  && (gfc_current_ns->proc_name->attr.proc == PROC_INTERNAL
+	      || gfc_current_ns->proc_name->attr.proc == PROC_MODULE)
 	  && gfc_current_ns->parent
 	  && (!(gfc_current_ns->parent->proc_name->attr.function
 		|| gfc_current_ns->parent->proc_name->attr.subroutine)
 	      || gfc_current_ns->parent->proc_name->attr.is_main_program))
 	{
 	  /* ... that is not a function...  */
-	  if (!gfc_current_ns->proc_name->attr.function)
+	  if (gfc_current_ns->proc_name
+	      && !gfc_current_ns->proc_name->attr.function)
 	    bad_proc = true;
 
 	  /* ... or is not an entry and has a different name.  */
Index: gcc/testsuite/gfortran.dg/null1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/null1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/null1.f90	(working copy)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/66045
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   contains
+   integer :: null=null() ! { dg-error "NULL appears on right-hand side" }
+end

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

* Re: [PATCH] fortran/66045 -- NULL() on RHS of assignment
  2015-05-15 15:19 [PATCH] fortran/66045 -- NULL() on RHS of assignment Steve Kargl
@ 2015-05-16 15:12 ` FX
  0 siblings, 0 replies; 2+ messages in thread
From: FX @ 2015-05-16 15:12 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches


>    PR fortran/66045
>    * expr.c (gfc_check_assign):  Check for assignment of NULL() instead
>    of the (intended) pointer assignment.

OK

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

end of thread, other threads:[~2015-05-16 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 15:19 [PATCH] fortran/66045 -- NULL() on RHS of assignment Steve Kargl
2015-05-16 15:12 ` FX

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