From patchwork Thu Dec 15 13:18:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 706080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tfYtL3TFxz9t0q for ; Fri, 16 Dec 2016 00:18:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wWPvWBDj"; dkim-atps=neutral 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=asRGHXFm9dMfiMsiktIcGclXvVY10Bps1DhH94SUagYm50 910ccYMHPFS7xkH0IT50xTpqc5tvl7bQGBxDXegEd4L2z7I7+mKE/bp07ASBvbyo 7TvgQDSz0gx5z4hD4MfkyVRDBgTo9o6vv7sFQTt3fhJoY97/dTC4JgC+MGtlc= 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=Fjioc+0z7zTLUJi2XUI/0SyPLOE=; b=wWPvWBDjRgnv84EDfQ5m GQmFXuQBwTIAFZxZWDFMJXsf+XCkFAB6rPGVd11D7oPdx7DhRK4xfmLyLSNwPnjk GB/GI3gqE6pIgvN/i3LmVD+l/g3n39D35kIJrg3/sH4jxBAZlqrp2UXohqtQmUBK rrVC6Au47x2RG2cycoH88UY= Received: (qmail 37524 invoked by alias); 15 Dec 2016 13:18:42 -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 37503 invoked by uid 89); 15 Dec 2016 13:18:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=12528 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yw0-f195.google.com Received: from mail-yw0-f195.google.com (HELO mail-yw0-f195.google.com) (209.85.161.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Dec 2016 13:18:31 +0000 Received: by mail-yw0-f195.google.com with SMTP id s68so1572542ywg.0; Thu, 15 Dec 2016 05:18:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=vYFL1jvHmI/gR6irAfw6IVwJw0OalxXFAEFl5hRSCTA=; b=Y0OBBixAvKKgHDB0M7N7eqbz9ekN688vjhRo4TkCyK0amdv1jOVVdTLZ0A2DVlphFU bBs0O0WgsYMin+DoeH+G/Ulf7oiuXO1liSsin2994cEDiJaDkORyUzi8rksnnQbp/IKl LLVmEbBZSzvSxZjtWMQ2K890SxoiVjKYKZsXfqvYkgpxvD6fQZNhOexcaL0OXAM/i7TN SxUGc5+6oXtTu6Gmy7c4OLng1PVzjFbUu9kO2M+6EkdnsYu0tE12GRdb3aGRuswuZyF9 /Xnku52gukRHzVA91u945zKZa0dOG4HiC5IUpHYXvKBuWQcya8fgDE6umPra9BZQAxY+ 3+cA== X-Gm-Message-State: AKaTC01cgdrL5Q/3eVvB26mkREYHhQRv4NsXJSkNVTSRcyryC7JKRDlm9skt45SDkw1wzibpYp7Ne3fBG9g1cg== X-Received: by 10.13.255.5 with SMTP id p5mr1096034ywf.60.1481807909256; Thu, 15 Dec 2016 05:18:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.51.145 with HTTP; Thu, 15 Dec 2016 05:18:28 -0800 (PST) From: Janus Weil Date: Thu, 15 Dec 2016 14:18:28 +0100 Message-ID: Subject: [Patch, Fortran, OOP] PR 78800: ICE in compare_parameter, at fortran/interface.c:2246 To: gfortran , gcc-patches Hi all, the attached patch deals with error recovery only and fixes an ICE-on-invalid problem. Regtests cleanly on x86_64-linux-gnu. Ok for trunk? Cheers, Janus 2016-12-15 Janus Weil PR fortran/78800 * interface.c (compare_allocatable): Avoid additional errors on bad class declarations. (compare_parameter): Put the result of gfc_expr_attr into a variable, in order to avoid calling it multiple times. Exit early on bad class declarations to avoid ICE. 2016-12-15 Janus Weil PR fortran/78800 * gfortran.dg/unlimited_polymorphic_27.f90: New test case. Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 243621) +++ gcc/fortran/interface.c (working copy) @@ -2075,13 +2075,13 @@ done: static int compare_allocatable (gfc_symbol *formal, gfc_expr *actual) { - symbol_attribute attr; - if (formal->attr.allocatable || (formal->ts.type == BT_CLASS && CLASS_DATA (formal)->attr.allocatable)) { - attr = gfc_expr_attr (actual); - if (!attr.allocatable) + symbol_attribute attr = gfc_expr_attr (actual); + if (actual->ts.type == BT_CLASS && !attr.class_ok) + return 1; + else if (!attr.allocatable) return 0; } @@ -2237,6 +2237,10 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a return 0; } + symbol_attribute actual_attr = gfc_expr_attr (actual); + if (actual->ts.type == BT_CLASS && !actual_attr.class_ok) + return 1; + if ((actual->expr_type != EXPR_NULL || actual->ts.type != BT_UNKNOWN) && actual->ts.type != BT_HOLLERITH && formal->ts.type != BT_ASSUMED @@ -2278,9 +2282,6 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a return 0; } - if (!gfc_expr_attr (actual).class_ok) - return 0; - if ((!UNLIMITED_POLY (formal) || !UNLIMITED_POLY(actual)) && !gfc_compare_derived_types (CLASS_DATA (actual)->ts.u.derived, CLASS_DATA (formal)->ts.u.derived)) @@ -2345,7 +2346,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a /* F2015, 12.5.2.8. */ if (formal->attr.dimension && (formal->attr.contiguous || formal->as->type != AS_ASSUMED_SHAPE) - && gfc_expr_attr (actual).dimension + && actual_attr.dimension && !gfc_is_simply_contiguous (actual, true, true)) { if (where) @@ -2406,7 +2407,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *a } if (formal->attr.allocatable && !formal->attr.codimension - && gfc_expr_attr (actual).codimension) + && actual_attr.codimension) { if (formal->attr.intent == INTENT_OUT) {