From patchwork Fri Dec 8 18:42:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 846393 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-468820-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="caJGmCux"; 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 3yth6l40Nkz9s83 for ; Sat, 9 Dec 2017 05:42:37 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=tAYyf61cAtGYc7UrOHoe9DtSfV1VsK2kmy+MyNfPygydPTOp1e 9pK+xeOHc+Vo0E/UbeFIfpBssYAE7mrPTS2Vd7H5bPlicULdKK0lZw9jIhXx3lp2 8aXXrAl02TtTrFcbTk4kjIbdmQkl2vXlO4UuJlPeHLrK5+zh3hHF4rZ9c= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=7BzZJcA27/N9HGuIY7wXzoWbjrk=; b=caJGmCuxUUvpCQKPffbJ 2u1pQM9RJjqZ9xOhDbuz/fEt+aCiAf8oaVmdjT3jdn1dIaBpG4x117QN2IxrXV5m uJ/XSERP+F94ImY2RhTiVCE1/cZYJiWR3lgLmqpUOp67UmddPUNv277tO2Xl1Pwj ocxalm6DXavu/s5skBnC1mw= Received: (qmail 46963 invoked by alias); 8 Dec 2017 18:42:30 -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 46935 invoked by uid 89); 8 Dec 2017 18:42:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*RU:sk:!192.16, Hx-spam-relays-external:sk:!192.16 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Dec 2017 18:42:26 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id A2E3312844; Fri, 8 Dec 2017 19:42:23 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id 963D311D76; Fri, 8 Dec 2017 19:42:23 +0100 (CET) Received: from [78.35.129.200] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 5a2add0f-02b8-7f0000012729-7f00000182c1-1 for ; Fri, 08 Dec 2017 19:42:23 +0100 Received: from [192.168.178.20] (xdsl-78-35-129-200.netcologne.de [78.35.129.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Fri, 8 Dec 2017 19:42:22 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 83316 Message-ID: <558c18e1-35bf-ee68-7271-cf9b8ae5cd94@netcologne.de> Date: Fri, 8 Dec 2017 19:42:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Hello world, the attached patch fixes a case where simplification wasn't done correctly for maxval and minval with character variables. Regression-tested. OK for trunk? Regards Thomas 2017-12-08 Thomas Koenig PR fortran/83316 * arith.c (gfc_character2character): New function. * arith.h: Add prototype. * simplify.c (gfc_convert_constant): Handle character type. 2017-12-08 Thomas Koenig PR fortran/83316 * gfortran.dg/minval_char_5.f90: New test. Index: arith.c =================================================================== --- arith.c (Revision 255181) +++ arith.c (Arbeitskopie) @@ -2514,7 +2514,19 @@ gfc_int2log (gfc_expr *src, int kind) return result; } +/* Convert character to character. We only use wide strings internally, + so we only set the kind. */ +gfc_expr * +gfc_character2character (gfc_expr *src, int kind) +{ + gfc_expr *result; + result = gfc_copy_expr (src); + result->ts.kind = kind; + + return result; +} + /* Helper function to set the representation in a Hollerith conversion. This assumes that the ts.type and ts.kind of the result have already been set. */ Index: arith.h =================================================================== --- arith.h (Revision 255181) +++ arith.h (Arbeitskopie) @@ -82,6 +82,7 @@ gfc_expr *gfc_hollerith2real (gfc_expr *, int); gfc_expr *gfc_hollerith2complex (gfc_expr *, int); gfc_expr *gfc_hollerith2character (gfc_expr *, int); gfc_expr *gfc_hollerith2logical (gfc_expr *, int); +gfc_expr *gfc_character2character (gfc_expr *, int); #endif /* GFC_ARITH_H */ Index: simplify.c =================================================================== --- simplify.c (Revision 255181) +++ simplify.c (Arbeitskopie) @@ -7130,6 +7130,13 @@ gfc_convert_constant (gfc_expr *e, bt type, int ki } break; + case BT_CHARACTER: + if (type == BT_CHARACTER) + f = gfc_character2character; + else + goto oops; + break; + default: oops: gfc_internal_error ("gfc_convert_constant(): Unexpected type");