From patchwork Thu May 2 06:02:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1093995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499966-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="r44eFnWY"; dkim-atps=neutral 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 44vl6y0pwsz9s55 for ; Thu, 2 May 2019 16:02:59 +1000 (AEST) 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:reply-to:mime-version:content-type; q=dns; s=default; b=mz4RhL0qGEay1Vxhym9oaGGRMGIVObj0GKn8iPjz564 0Qf+Q1BYapbkCk8as41HJHDCNXbeTiAp3JzDo81JSWKNhsQcVQ1Rk9RPVu+QfjHi vZPyJZTRgXsQDVSCrv0FjkhyWd9nQa6NAuj96iaKKZ6SQ9b3EfsuSseBSPS+xcmw = 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:reply-to:mime-version:content-type; s=default; bh=QUBp+HCATtyiodqjUf6iA41Cb4U=; b=r44eFnWYiwBf8BxzL dk3WPHGUOP5OFNRGt3e2P41XBMNrZfQvm5ex6FM7FRtidoT+AdK0zb2ypVmYp0QG eH0rDokRHhm3uNlzNj4QEpwMPfIDgVlFk3qmu4yhwbNClaM0otRnZxZZjiJTOvsC iYlSi+Kk47tWRtV6hRALPO5RZo= Received: (qmail 62262 invoked by alias); 2 May 2019 06:02:48 -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 62244 invoked by uid 89); 2 May 2019 06:02:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=H*MI:edu, f95, F2008 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 ESMTP; Thu, 02 May 2019 06:02:46 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x4262h7n053147 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 1 May 2019 23:02:43 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x4262hav053146; Wed, 1 May 2019 23:02:43 -0700 (PDT) (envelope-from sgk) Date: Wed, 1 May 2019 23:02:43 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/90290 -- Check F2008 STOP code Message-ID: <20190502060243.GA53139@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.2 (2019-01-07) The attach patch adds an additional check for the STOP code when -std=f2008 is used. The patch has been bootstrapped and regression tested on x86_64-*-freebsd for trunk. OK to commit? 2019-05-01 Steven G. Kargl PR fortran/90290 * match.c (gfc_match_stopcode): Check F2008 condition on stop code. 2019-05-01 Steven G. Kargl PR fortran/90290 * gfortran.dg/pr90290.f90: New test. Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 270774) +++ gcc/fortran/match.c (working copy) @@ -2955,7 +2955,7 @@ gfc_match_stopcode (gfc_statement st) { gfc_expr *e = NULL; match m; - bool f95, f03; + bool f95, f03, f08; /* Set f95 for -std=f95. */ f95 = (gfc_option.allow_std == GFC_STD_OPT_F95); @@ -2963,6 +2963,9 @@ gfc_match_stopcode (gfc_statement st) /* Set f03 for -std=f2003. */ f03 = (gfc_option.allow_std == GFC_STD_OPT_F03); + /* Set f08 for -std=f2008. */ + f08 = (gfc_option.allow_std == GFC_STD_OPT_F08); + /* Look for a blank between STOP and the stop-code for F2008 or later. */ if (gfc_current_form != FORM_FIXED && !(f95 || f03)) { @@ -3051,8 +3054,8 @@ gfc_match_stopcode (gfc_statement st) /* Test for F95 and F2003 style STOP stop-code. */ if (e->expr_type != EXPR_CONSTANT && (f95 || f03)) { - gfc_error ("STOP code at %L must be a scalar CHARACTER constant or " - "digit[digit[digit[digit[digit]]]]", &e->where); + gfc_error ("STOP code at %L must be a scalar CHARACTER constant " + "or digit[digit[digit[digit[digit]]]]", &e->where); goto cleanup; } @@ -3061,6 +3064,14 @@ gfc_match_stopcode (gfc_statement st) gfc_init_expr_flag = true; gfc_reduce_init_expr (e); gfc_init_expr_flag = false; + + /* Test for F2008 style STOP stop-code. */ + if (e->expr_type != EXPR_CONSTANT && f08) + { + gfc_error ("STOP code at %L must be a scalar default CHARACTER or " + "INTEGER constant expression", &e->where); + goto cleanup; + } if (!(e->ts.type == BT_CHARACTER || e->ts.type == BT_INTEGER)) { Index: gcc/testsuite/gfortran.dg/pr90290.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr90290.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr90290.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +program errorstop + integer :: ec + read *, ec + stop ec ! { dg-error "STOP code at " } +end program