From patchwork Fri May 15 15:17:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 472835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48C84140B0E for ; Sat, 16 May 2015 01:18:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Mkfj/l7Z; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GB7GBgnJELqXiA7ADLx9KR0DtNSggVsISx07n+mO72CytxXmZVoF0 Tpthqg6NzXcbT3WoloX1VXhPgyyiq2p/dGyMTtPOW3Fqo1CFyML7nA++MUFgPmHe EQad10EvKwVDvoam6sVbBkppYd1ym7DQcbZHTqC+WgHlKIgUokbqt4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=cA59ZIbhia0Vw+fPp2d0hr2uKk8=; b=Mkfj/l7ZHSRu8iC5zNRL 8GTUe119VZ/u3arr4b7Fr8vGRHbv+K0CfjTxF9k8ojlMxsFp1PW6ykq/xVUVx/Ox 7ApDtd2IQoLvLf7yLBnQX5/ReQp4TFVL7FOc9lkAqmlnSogOU9kGHAAo1nfWtMPz +3Rx6lxPWAbsISBsqiXGJMg= Received: (qmail 64157 invoked by alias); 15 May 2015 15:18:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 64138 invoked by uid 89); 15 May 2015 15:18:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 May 2015 15:17:45 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id t4FFHhE7083005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 15 May 2015 08:17:43 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id t4FFHgnn083004; Fri, 15 May 2015 08:17:42 -0700 (PDT) (envelope-from sgk) Date: Fri, 15 May 2015 08:17:42 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] fortran/66045 -- NULL() on RHS of assignment Message-ID: <20150515151742.GF82729@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Regression tested on trunk. OK to commit? The patch is self-explanatory. Steven G. Kargl 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 PR fortran/66045 * gfortran.dg/null1.f90: New test. 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 +! +program p + contains + integer :: null=null() ! { dg-error "NULL appears on right-hand side" } +end