From patchwork Sun Sep 22 20:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 1165779 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-509422-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="G4YY+2OA"; 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 46c04k3yvLz9s4Y for ; Mon, 23 Sep 2019 06:52:04 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ETNdjb1bhQTRyyfj44lEn28KTIF7q8iZEXsQcltdORI7O/uOs4 +Jantzn0MgxBReaaqUV9/qtD/7sAwo5I/rbaFWnvPyBRkaFahj40VjWGfzFkGBF4 FxmJMoC0tf4nkSHHCYvRqXixLqKSxvMctVtH60xeB5QIjXgeJ2mEmCWtw= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=zQbCXDJNtdZde5AXITHieqRw/f4=; b=G4YY+2OAvKv7ceGub0iL tOKaTnnH1HWX8tNxsQV60iS0GuU8rhROFCzVp4OdQhKcJlN52mraKo2YZOVSyhGq A/fnJC7OVZ+6vWS+DvzHC3+o08BzKBY/Mhi4jjPPzDq51d7BfNm7/XMFVKbeWD7Y 0/3ohHCe4ruuTd4Yc526u+Q= Received: (qmail 118478 invoked by alias); 22 Sep 2019 20:51:50 -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 118458 invoked by uid 89); 22 Sep 2019 20:51:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Jerry, 1051, st_parameter_dt, kin X-HELO: impout003.msg.chrl.nc.charter.net Received: from impout003aa.msg.chrl.nc.charter.net (HELO impout003.msg.chrl.nc.charter.net) (47.43.20.27) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 22 Sep 2019 20:51:49 +0000 Received: from [192.168.1.6] ([66.191.41.128]) by cmsmtp with ESMTPA id C8peiBtzfnJPnC8pfiE5sS; Sun, 22 Sep 2019 20:51:47 +0000 Authentication-Results: charter.net; none To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [patch, libgfortran] Bug 91593 - Implicit enum conversions in libgfortran/io/transfer.c Message-ID: <7fb106f7-31f3-9d4c-3610-270c3162164d@charter.net> Date: Sun, 22 Sep 2019 13:51:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 Hi all, The attached patch eliminates several warnings by adjusting which enumerator is used in the subject offending code. I fixed this by adding an enumerator at the end of the file_mode definition. This then triggered a warning in several other places for an unhandled case in the switch statements. I cleared those by throwing in an assert (false) since it cant happen unless something really goes wrong somehow. Regardless, regression tested on x86_64-pc-linux-gnu. OK for trunk? No applicable test case. Jerry 2019-09-22 Jerry DeLisle PR libfortran/91593 * io/transfer.c (file_mode, current_mode, formatted_transfer_scalar_read, formatted_transfer_scalar_write, pre_position, next_record_r, next_record_w): Add and use FORMATTED_UNSPECIFIED to enumeration. PS While I was at it, I 'touched' all files in libgfortran/io to see what other warnings are left, There is another odd warning I have not sorted out yet. ../../../trunk/libgfortran/io/read.c: In function ‘read_decimal’: ../../../trunk/libgfortran/io/read.c:641:9: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 641 | if (w == DEFAULT_WIDTH) | ^~ In function ‘btoa_big’, inlined from ‘write_b’ at ../../../trunk/libgfortran/io/write.c:1212:11: ../../../trunk/libgfortran/io/write.c:1051:6: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 1051 | *q = '\0'; | ~~~^~~~~~ The first of these two I understand. The second one about region of size 0 puzzles me. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index c43360f6332..3ba72a47d3e 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -32,6 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "format.h" #include "unix.h" #include "async.h" +#include #include #include @@ -193,7 +194,8 @@ static const st_option async_opt[] = { typedef enum { FORMATTED_SEQUENTIAL, UNFORMATTED_SEQUENTIAL, - FORMATTED_DIRECT, UNFORMATTED_DIRECT, FORMATTED_STREAM, UNFORMATTED_STREAM + FORMATTED_DIRECT, UNFORMATTED_DIRECT, FORMATTED_STREAM, + UNFORMATTED_STREAM, FORMATTED_UNSPECIFIED } file_mode; @@ -203,7 +205,7 @@ current_mode (st_parameter_dt *dtp) { file_mode m; - m = FORM_UNSPECIFIED; + m = FORMATTED_UNSPECIFIED; if (dtp->u.p.current_unit->flags.access == ACCESS_DIRECT) { @@ -1727,17 +1729,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 = SIGN_PROCDEFINED; break; case FMT_SS: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SS; + dtp->u.p.sign_status = SIGN_SUPPRESS; break; case FMT_SP: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SP; + dtp->u.p.sign_status = SIGN_PLUS; break; case FMT_BN: @@ -2186,17 +2188,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 = SIGN_PROCDEFINED; break; case FMT_SS: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SS; + dtp->u.p.sign_status = SIGN_SUPPRESS; break; case FMT_SP: consume_data_flag = 0; - dtp->u.p.sign_status = SIGN_SP; + dtp->u.p.sign_status = SIGN_PLUS; break; case FMT_BN: @@ -2766,6 +2768,8 @@ pre_position (st_parameter_dt *dtp) case UNFORMATTED_DIRECT: dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl; break; + case FORMATTED_UNSPECIFIED: + assert (false); /* Should never happen. */ } dtp->u.p.current_unit->current_record = 1; @@ -3637,6 +3641,8 @@ next_record_r (st_parameter_dt *dtp, int done) while (p != '\n'); } break; + case FORMATTED_UNSPECIFIED: + assert (false); /* Should never happen. */ } } @@ -4002,6 +4008,8 @@ next_record_w (st_parameter_dt *dtp, int done) } break; + case FORMATTED_UNSPECIFIED: + assert (false); /* Should never happen. */ io_error: generate_error (&dtp->common, LIBERROR_OS, NULL);