From patchwork Thu Jan 17 06:30:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1026414 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-494214-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="O7aqRc0k"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="nyfAzRzT"; 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 43gDk03gDpz9sD9 for ; Thu, 17 Jan 2019 17:31:18 +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=a37Y49IuM756Ae0994Yk0T3GUstg0PIDHqkwODAsGJzVT4day2 FkLW0P5gFaoVYoctO8Z35W36OImh/hnFTwi16ThFJlmB56JDrgaE9AhXVBBbn2T3 87BDVpR1f8ywm56lWYFWvwj1+AS0HzotlgeJOyPbf6inLKeOAzg1TIiCs= 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=ZinwkanRnk87tGaWTZR+jijDEhM=; b=O7aqRc0k4lEdAx+wi8bl tVyV7BTswqa9d7fJRegj4YIYzhC0BLk+g4AAD2iA1Ae6eJlILMzS2OxadR/mEujZ pkULkcRHYTRVfFDBCJ7Vh2eUxD4CAuglhrcyep/xx6RtlBjOkeIaRvbAEbxmKuiV +Sx9tTwhDOIONI08ZyT8w8k= Received: (qmail 82213 invoked by alias); 17 Jan 2019 06:31:04 -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 82032 invoked by uid 89); 17 Jan 2019 06:30:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=BAYES_50, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=expr_substring, EXPR_SUBSTRING, equal_length, sk:regress 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; Thu, 17 Jan 2019 06:30:43 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 7C1F11283B; Thu, 17 Jan 2019 07:30:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1547706636; bh=fYrL0Cq7yunuAfmEcliCuPSNdYe4/GELBzruc8pW3CI=; h=To:From:Subject:Message-ID:Date:From; b=nyfAzRzTpNWFwDkCVl8pvUsQ74+dG2hw3oE6AUoCe8koqomlM/LMA3BjzpmwPaBpd rBqxzToEExcAqkR+0aPXeG3c+oPl6j100OEHZHMoCGfYY8cNno9QD0tI0Od+z5Nnkr QXggD3JfXgFtTqpA1vCFYIdTFhW4Je1HHzBfI0ZyjnJSELQVgu67bbDL/s6HqfvFOC dXLdZa78Qn98i4Qz4A5MzATMmaUXkWTXWFDbvvVatpd1M7MhxqvpDsn6p6u04RpPVP 2wFzvX/f/T9Teb6leKYgWE50ETMDXosj1L507dGaOGGc2jcQZuzqJ39+7R753UlM1P 4aK0MK4b0nKKg== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 7886811EBB; Thu, 17 Jan 2019 07:30:36 +0100 (CET) Received: from [78.35.145.129] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c40210c-0bea-7f0000012729-7f0000018800-1 for ; Thu, 17 Jan 2019 07:30:36 +0100 Received: from [192.168.178.68] (xdsl-78-35-145-129.nc.de [78.35.145.129]) (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; Thu, 17 Jan 2019 07:30:35 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 88871 Message-ID: <61631d6c-bf99-b4c9-227d-45a254a2d007@netcologne.de> Date: Thu, 17 Jan 2019 07:30:34 +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, the attached patch fixes PR 88871, a regression introduced by my recent patch for removing unnecessary substrings. Regression-tested; this now also works with valgrind on Linux, where the failure did not show up otherwise. No test case because, well - it did show up on a few systems, so we will notice if it regresses. OK for trunk? Regards Thomas 2019-01-17 Thomas Koenig PR fortran/88871 * resolve.c (resolve_ref): Fix logic for removal of reference. Index: resolve.c =================================================================== --- resolve.c (Revision 267953) +++ resolve.c (Arbeitskopie) @@ -5046,6 +5046,7 @@ resolve_ref (gfc_expr *expr) int current_part_dimension, n_components, seen_part_dimension; gfc_ref *ref, **prev; bool equal_length; + bool breakout; for (ref = expr->ref; ref; ref = ref->next) if (ref->type == REF_ARRAY && ref->u.ar.as == NULL) @@ -5054,12 +5055,12 @@ resolve_ref (gfc_expr *expr) break; } - - for (ref = expr->ref, prev = &expr->ref; ref; prev = &ref->next, ref = ref->next) - switch (ref->type) + breakout = false; + for (prev = &expr->ref; !breakout && *prev != NULL; prev = &(*prev)->next) + switch ((*prev)->type) { case REF_ARRAY: - if (!resolve_array_ref (&ref->u.ar)) + if (!resolve_array_ref (&(*prev)->u.ar)) return false; break; @@ -5069,17 +5070,20 @@ resolve_ref (gfc_expr *expr) case REF_SUBSTRING: equal_length = false; - if (!resolve_substring (ref, &equal_length)) + if (!resolve_substring (*prev, &equal_length)) return false; if (expr->expr_type != EXPR_SUBSTRING && equal_length) { /* Remove the reference and move the charlen, if any. */ + ref = *prev; *prev = ref->next; ref->next = NULL; expr->ts.u.cl = ref->u.ss.length; ref->u.ss.length = NULL; gfc_free_ref_list (ref); + if (*prev == NULL) + breakout = true; } break; }