From patchwork Tue Sep 12 11:38:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 812804 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-461908-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="KOLVIWy2"; 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 3xs2qy6fbRz9s82 for ; Tue, 12 Sep 2017 21:38:53 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=J5531AvPFxFGaSwXT3FYTNLlXvwbZssIF6CQeemZGfqvqK lWVcppZW5bcvoXi/0T2w2HgWJIgzVqgV0Cak4TWM8G0IOP8QorQQspnRgl6BdxsG nw3Ifp/5/3o8lWLnKAELdxQqTGBJqZGXNIiEyQ3bt8Qg18Jh4IB1x3Jtz3YHc= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=AMOFoHLLCcs+ld/2wjsYVoWkWIY=; b=KOLVIWy2fRZCWQI7Laoy aktb+qgaurVjsfHjruQo3Vw3OUTbBhcvZrVmItcvFwwJuhCjsowmYrADlHQrZxgI dewvsdtsq/Blgu/ZWvdKut5KCmPjQeE3tFop1DZhz+HiL/f79rF0rszVUUxwpTa2 k0pyIbmGR5oMz2JeknZE8hA= Received: (qmail 59558 invoked by alias); 12 Sep 2017 11:38:47 -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 59539 invoked by uid 89); 12 Sep 2017 11:38:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Cast, kin, UD:access, sk:consume X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Sep 2017 11:38:44 +0000 Received: by mail-wr0-f173.google.com with SMTP id m18so21078345wrm.2 for ; Tue, 12 Sep 2017 04:38:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+fp2auHmRSesRGZLQTxWx/tWyD4VSlCyJgNVOiArONk=; b=qtVo8E2niEyY0Y6K4BZ+2hGiEcB8YezTO5TCgv3Fsfr5rhtxoQuwPyxwOquYAqJ8Xc r4B7S0xROvofyy748x4bEJ21Lz6/mPs/YCf3ky446wWHOVKlVk8RYaKGwhXa8dhPJPJ7 Lc2Qj8GbxDjTqfDIGWlMFMlze6T9rb6IQQHa655d2XT/LDiraqb9dyEaETFabNfmROCl jJ56PhyYFNOa8pR5WDAFRYNae5EjfdqcmVXAOdCnpo+D7F/vBBouLG3dSK6Yl2DN0bHx 5nKLFBpmkOKkzS45JQsMQYAlcB5cUb/mm7OAp85za78WtD4btog/7b5kDNXEGGdBP98n EXbA== X-Gm-Message-State: AHPjjUjgc8dXh6/nuUPqBqn5aYU+socTpbqYrjWsoU+w8Z9wCdDmYGkl 0Y5h4hcw4zZklV1YBRbb4ZWYbky2JMZvT6g3tA== X-Google-Smtp-Source: ADKCNb4iW3SRZ0TGioFxr+BtiSa7k8pPh65szKd3Jh3lxqwWSypF/Fmd7iSV15k6CDPzVtv/1gYdXIgiwvcT69VNnMc= X-Received: by 10.223.138.235 with SMTP id z40mr12911671wrz.14.1505216321792; Tue, 12 Sep 2017 04:38:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.130.110 with HTTP; Tue, 12 Sep 2017 04:38:40 -0700 (PDT) From: Prathamesh Kulkarni Date: Tue, 12 Sep 2017 17:08:40 +0530 Message-ID: Subject: [libgfortran] Replace implicit conversions between enums in io/transfer.c by explicit casts. To: gcc Patches , fortran@gcc.gnu.org X-IsSubscribed: yes Hi, I am working on patch for PR78736 (https://gcc.gnu.org/ml/gcc-patches/2017-09/msg00011.html), which adds a new warning -Wenum-conversion to C front-end to warn for implicit conversion between different enums. The warning in that patch triggered on io/transfer.c for following implicit conversions: i) Implicit conversion from unit_mode to file_mode ii) Implicit conversion from unit_sign_s to unit_sign. I was wondering if the warning for above implicit conversions would be correct since unit_mode and file_mode are different enums and similarly unit_sign_s and unit_sign are different enums ? Or are these warnings false positives ? The attached patch makes the conversion explicit to silence the warnings. Bootstrap+tested on x86_64-unknown-linux-gnu. Does the patch look OK ? Thanks, Prathamesh 2017-09-12 Prathamesh Kulkarni libgfortran/ * io/transfer.c (current_mode): Cast FORM_UNSPECIFIED to file_mode. (formatted_transfer_scalar_read): Cast SIGN_S, SIGN_SS, SIGN_SP to unit_sign. (formatted_transfer_scalar_write): Likewise. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 529637061b1..3307d213bb7 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -196,7 +196,7 @@ current_mode (st_parameter_dt *dtp) { file_mode m; - m = FORM_UNSPECIFIED; + m = (file_mode) FORM_UNSPECIFIED; if (dtp->u.p.current_unit->flags.access == ACCESS_DIRECT) { @@ -1671,17 +1671,17 @@ formatted_transfer_scalar_read (st_parameter_dt *dtp, bt type, void *p, int kind case FMT_S: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_S; + dtp->u.p.sign_status = (unit_sign) SIGN_S; break; case FMT_SS: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SS; + dtp->u.p.sign_status = (unit_sign) SIGN_SS; break; case FMT_SP: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SP; + dtp->u.p.sign_status = (unit_sign) SIGN_SP; break; case FMT_BN: @@ -2130,17 +2130,17 @@ formatted_transfer_scalar_write (st_parameter_dt *dtp, bt type, void *p, int kin case FMT_S: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_S; + dtp->u.p.sign_status = (unit_sign) SIGN_S; break; case FMT_SS: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SS; + dtp->u.p.sign_status = (unit_sign) SIGN_SS; break; case FMT_SP: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SP; + dtp->u.p.sign_status = (unit_sign) SIGN_SP; break; case FMT_BN: