From patchwork Sat Oct 5 16:21:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1172233 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-510348-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="EgdRcEQe"; 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 46lsSP6tQTz9sPh for ; Sun, 6 Oct 2019 03:21:23 +1100 (AEDT) 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=D9vY5egiGWO/Mj2VZhUcLxInvsMzCsufi3O5eFbMVWu thFHMXwyInt8HZ3v3fqHdW6eXCn0yxwl83IVCipX+IuHT9WvDxDoPNSa/26hnV7H PH8M00XfAKUuPX1xLhLfGKMbmZeSOa1rb6oTRlOfpOYz3o4+sXmE+qi7Z3vT5nzw = 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=lnTlUzIFCli+Dz/LU5mDQ1WLJeU=; b=EgdRcEQeIj5nO7IkO yOyCSTvU8fPu30bbUBPqgn1D9NajpyPMD44RKQ0VVBLUUnMJ3jxldRAXJAmcpZMb wShm0DPWjEY9fHZaWGsEICSQf8xkYQnCJpcnzZ42y+VeAU9oYr2Frn3wtcbc26Vs cfiq1Y28YcohzUjdRuCI54tmgY= Received: (qmail 108543 invoked by alias); 5 Oct 2019 16:21:14 -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 108527 invoked by uid 89); 5 Oct 2019 16:21:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy= 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; Sat, 05 Oct 2019 16:21:12 +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 x95GLABd042428 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 5 Oct 2019 09:21:10 -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 x95GLAEC042313; Sat, 5 Oct 2019 09:21:10 -0700 (PDT) (envelope-from sgk) Date: Sat, 5 Oct 2019 09:21:10 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/91801 -- convert assert to an error Message-ID: <20191005162110.GA9763@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Tested on x86_64-*-freebsd. OK to commit? The error message says it all. 2019-10-05 Steven G. Kargl PR fortran/91801 * simplify.c (gfc_simplify_reshape): Convert a gcc_assert into a gfc_error as a user can easily hit the condition. 2019-10-05 Steven G. Kargl PR fortran/91801 * gfortran.dg/pr91801.f90: New test. Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (revision 276628) +++ gcc/fortran/simplify.c (working copy) @@ -6762,7 +6762,15 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shap gfc_extract_int (e, &order[i]); - gcc_assert (order[i] >= 1 && order[i] <= rank); + if (order[i] < 1 || order[i] > rank) + { + gfc_error ("Element with a value of %d in ORDER at %L must be " + "in the range [1, ..., %d] for the RESHAPE intrinsic " + "near %L", order[i], &order_exp->where, rank, + &shape_exp->where); + return &gfc_bad_expr; + } + order[i]--; if (x[order[i]] != 0) { Index: gcc/testsuite/gfortran.dg/pr91801.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91801.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91801.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/91801 +! Code contributed by Gerhard Steinmetz +program p + integer, parameter :: a(2) = [2,0] ! { dg-error "Element with a value of" } + print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "for the RESHAPE intrinsic near" } +end