From patchwork Tue Jan 1 18:42:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1019789 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-493241-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="D+3jcWDr"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="I3xPLMOE"; 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 43Tjj709fdz9s4s for ; Wed, 2 Jan 2019 05:42:33 +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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=UVn38FvXWwL7t+66a81BDYVfKx6XQAD3cqXMP9Fu7oxIYxWtUz Wu97oMYfSVMIfpbIPP7fY64IxdIf7ZQDOgtMbBACHxQKW7z09r2SGZMPMmsngm+r t7h2HjKkH29gsWFygvZ5KzdafDUR45iZB3xaHlKo9Dnd9RGDMVdGCm7jI= 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=L3z8PVTmGwCp+bg6kdqqfW9bvl8=; b=D+3jcWDrj9PT0e8+5tpf AzyE3N8or9Cohr1G7GKrsRmTUaAFgCYCAZCaoRDoYEM6lUTJlLZuyEZmOL2sfIJO HwnPrj4LFaZ5b/a9t7jat76xZqMmD6WBpEZWYBpmuCnFOLU3TwTyVfBpJsumyxBR F+Z7HPzXYWccjjT5ruX8zqc= Received: (qmail 100860 invoked by alias); 1 Jan 2019 18:42:22 -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 100842 invoked by uid 89); 1 Jan 2019 18:42:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=BAYES_20, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=towards, U*tkoenig, sk:tkoenig, H*r:sk:xdsl-78 X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Jan 2019 18:42:20 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 636E713396; Tue, 1 Jan 2019 19:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1546368137; bh=jIWlT7GzhDMJDrkpkXT2TWgwnJmo18JZQ4Qn/49Hmiw=; h=To:Cc:From:Subject:Message-ID:Date:From; b=I3xPLMOEkjjqmTgbmsUu7cC8PzFXyYuY/QjjzwAtVbb3vs5whl0p6P5DIw2WxLfUD 0bMJQy1kbJ+M5JGqBhUY+tKnxIboMej7XSjsiPYcols1bxJH7IWawrVf+FuNk46UGa JVxxUFqBLeENCAyIFtwywXNpBL8B+VXMrQwg4GTUM1tAgI9QSLm5ddE52uJxho/RKh VUteVhg6WzaDJUJ78IgbfnX9Snj9JRJai54jOySIB0xrA/9xUfqWnEpxJj+QtaYrbr RFcOy23ZnMyn27C3iEKQPReb/sM9QYGOKALjN20p9hSl7ls2IUAEfPyk0tWjAtxnjO XtmSTdusjuoNw== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 5F2FE11EBD; Tue, 1 Jan 2019 19:42:17 +0100 (CET) Received: from [78.35.135.87] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c2bb489-0bea-7f0000012729-7f000001c4be-1 for ; Tue, 01 Jan 2019 19:42:17 +0100 Received: from [192.168.178.68] (xdsl-78-35-135-87.nc.de [78.35.135.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Tue, 1 Jan 2019 19:42:15 +0100 (CET) To: "fortran@gcc.gnu.org" Cc: gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 82743, warning for truncation on constructors Message-ID: <75946d6e-4207-cd5e-a51a-c40ccb39db2a@netcologne.de> Date: Tue, 1 Jan 2019 19:42:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Hello world, first of all, Happy New Year to everybody! In 2018, we fixed 333 bugs, an average of 0.91 per day. Not bad at all. Here is a first contribution towards reaching something similar, or even better, for 2019. It is a rather straightforward patch which adds a missing warning for truncated strings in constructors. Regression-tested. OK for trunk? Regards Thomas 2019-01-01 Thomas Koenig PR fortran/82743 * primary.c (gfc_convert_to_structure_constructor): If a character in a constructor is too long, add a warning with -Wcharacter-truncation. 2019-01-01 Thomas Koenig PR fortran/82743 * gfortran.dg/structure_constructor_16.f90: New test. Index: primary.c =================================================================== --- primary.c (Revision 267335) +++ primary.c (Arbeitskopie) @@ -3074,6 +3074,12 @@ gfc_convert_to_structure_constructor (gfc_expr *e, actual->expr->value.character.length = c; actual->expr->value.character.string = dest; + + if (warn_line_truncation && c < e) + gfc_warning_now (OPT_Wcharacter_truncation, + "CHARACTER expression will be truncated " + "in constructor (%ld/%ld) at %L", (long int) c, + (long int) e, &actual->expr->where); } }