From patchwork Tue Feb 19 21:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1044905 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-496666-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bzTdRfG8"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="abX9tdQZ"; 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 443vXV3CySz9s3l for ; Wed, 20 Feb 2019 08:49:43 +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=RX1UTA5jvdtrbB6xklwmfmAX4TzldQr9lCHrgFBGSc6IhnIg9J rUYsm70c2mYOCC8b8+UEG/07JwnGy0rJRAu1eDxCt2ex/A/wDvnVtyfu6zPOLOSN 7kRW/uRGfyrTJgjSTAeIBjCfXAzXbUQouoHCJYGGHWFF+OYFHwnv9kpQw= 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=CYp2QpB8ZR29gcvb9e7qNu8XPo4=; b=bzTdRfG8lo1yDfqM1jKG x/GidHRCKv3cPGe5Wee9tUJBrpaR40oUdPhvit1fKRsEoeFjiFShx2s9HF8gnj+S 9DrwHnBc7Ks/Sm9OB8gD0BCSZ6hqO6uOQ/qGzHPuBboJCC+9KiGIY3Cg0oa4+Di4 gXKkRj9xvUTnIys/5uN9Kt4= Received: (qmail 38220 invoked by alias); 19 Feb 2019 21:49:31 -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 38186 invoked by uid 89); 19 Feb 2019 21:49:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=wconversion, Wconversion, gfc_symbol X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Feb 2019 21:49:28 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 5EBD81259B; Tue, 19 Feb 2019 22:49:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1550612965; bh=fNKecwgWoDEpAQJPUGGcuyRvgex8ft4Q3XU78krz2AQ=; h=To:From:Subject:Message-ID:Date:From; b=abX9tdQZP85eUlYQ4KTWyTayySOJ7pMmQErxK4gBq5lyqqgCuxsz0N4ECVhA6QXD8 F57Mu2AxOdMtXe3rMRByIf0Tr49RRi2hwbDFyRWtj08FVB2uBwdogfY5gGawdYoAoA KpfiPTK/ev1Rfzs1nk0dwkD1UjnicmVut56aHqQuEA6f4vziY+BN+F2/naN9w1DLLe uCyR+qKXZEnJrp/kMNPtr7Iw7dWvMcbBHIBeAeDq8JEBLvqDblTuMSigA0hG2hVF2p dBbMebEJbJoTW9uSs9xdx85Rw5Tjg7+ZvBWvlJAn/UZkackg/tNO3/nN/veqMjjQIy Q9bZ5zppxutrA== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id 51D9B11D85; Tue, 19 Feb 2019 22:49:25 +0100 (CET) Received: from [2001:4dd7:2221:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c6c79e5-5f8a-7f0000012729-7f000001815e-1 for ; Tue, 19 Feb 2019 22:49:25 +0100 Received: from [IPv6:2001:4dd7:2221:0:7285:c2ff:fe6c:992d] (2001-4dd7-2221-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:2221:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Tue, 19 Feb 2019 22:49:22 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 86119, spurios warning for len(classtype) with -Wconversion Message-ID: <8b2fbdd5-0ae9-ae18-c004-b2a2979c8bda@netcologne.de> Date: Tue, 19 Feb 2019 22:49:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 Hello world, the attached patch fixes the 8/9 regression by inserting the conversion at the right place. Regression-tested. OK for trunk, and for 8 when it re-opens? Regards Thomas 2019-02-19 Thomas Koenig PR fortran/86110 * class.c (gfc_get_len_component): Add argument k for kind. If the kind of the resulting expression is not equal to k, convert it. * gfortran.h (gfc_len_component): Adjust prototype. * simplify.c (gfc_simplify_len): Pass kind to gfc_get_len_component. 2019-02-19 Thomas Koenig PR fortran/86110 * gfortran.dg/warn_conversion_11.f90: New test. Index: class.c =================================================================== --- class.c (Revision 268968) +++ class.c (Arbeitskopie) @@ -565,7 +565,7 @@ gfc_intrinsic_hash_value (gfc_typespec *ts) ref to the _len component. */ gfc_expr * -gfc_get_len_component (gfc_expr *e) +gfc_get_len_component (gfc_expr *e, int k) { gfc_expr *ptr; gfc_ref *ref, **last; @@ -590,6 +590,14 @@ gfc_expr * } /* And replace if with a ref to the _len component. */ gfc_add_len_component (ptr); + if (k != ptr->ts.kind) + { + gfc_typespec ts; + gfc_clear_ts (&ts); + ts.type = BT_INTEGER; + ts.kind = k; + gfc_convert_type_warn (ptr, &ts, 2, 0); + } return ptr; } Index: gfortran.h =================================================================== --- gfortran.h (Revision 268968) +++ gfortran.h (Arbeitskopie) @@ -3479,7 +3479,7 @@ bool gfc_is_class_scalar_expr (gfc_expr *); bool gfc_is_class_container_ref (gfc_expr *e); gfc_expr *gfc_class_initializer (gfc_typespec *, gfc_expr *); unsigned int gfc_hash_value (gfc_symbol *); -gfc_expr *gfc_get_len_component (gfc_expr *e); +gfc_expr *gfc_get_len_component (gfc_expr *e, int); bool gfc_build_class_symbol (gfc_typespec *, symbol_attribute *, gfc_array_spec **); gfc_symbol *gfc_find_derived_vtab (gfc_symbol *); Index: simplify.c =================================================================== --- simplify.c (Revision 268968) +++ simplify.c (Arbeitskopie) @@ -4474,7 +4474,7 @@ gfc_simplify_len (gfc_expr *e, gfc_expr *kind) /* The expression in assoc->target points to a ref to the _data component of the unlimited polymorphic entity. To get the _len component the last _data ref needs to be stripped and a ref to the _len component added. */ - return gfc_get_len_component (e->symtree->n.sym->assoc->target); + return gfc_get_len_component (e->symtree->n.sym->assoc->target, k); else return NULL; }