From patchwork Mon Sep 3 19:19:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 965635 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-485044-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="alLKofxf"; 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 4243vd5TQCz9rvt for ; Tue, 4 Sep 2018 08:06:20 +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=dgkLsEdYZJlltfjyTONAyQ9KSnXjkHsV4BShBbn+CmEw/3 ETdlSZ2OJD7yd+WgvrEQjnbMCStEEnsyMZ5n95/Ib4B4wVJuLfNwzPg+VMYalwcQ 1gndLpStk6ETEjK8GO5xH9NA74TDB3Z0LN0dCNXxucGLmIhT9fML9+tgDmyGU= 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=5nTFVs01pL3a+qzpbdfzlW3ekU8=; b=alLKofxfve5tayyaln9b +Qr7emtcrO7b6+fh3JgsAwvFhY57Xzt4Ox4gI32v7pBpLYHtiaPInBtp7+tosLt8 U2XXyQ6XlVDEYvh7RCxDfpi82mOBzuniZehc8iLDXa0bIV3X+wI/l/Sooul8+aUL up/BR5yeU/Uoor2g7Avkfd4= Received: (qmail 105011 invoked by alias); 3 Sep 2018 19:19:35 -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 104934 invoked by uid 89); 3 Sep 2018 19:19:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-HELO:sk:mail-yw, HX-Received:a81, janus, iso_c_binding X-HELO: mail-yw1-f45.google.com Received: from mail-yw1-f45.google.com (HELO mail-yw1-f45.google.com) (209.85.161.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Sep 2018 19:19:30 +0000 Received: by mail-yw1-f45.google.com with SMTP id 14-v6so473155ywe.2; Mon, 03 Sep 2018 12:19:30 -0700 (PDT) MIME-Version: 1.0 From: Janus Weil Date: Mon, 3 Sep 2018 21:19:17 +0200 Message-ID: Subject: [Patch, Fortran] PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782 To: gfortran , gcc-patches Hi all, attached is a simple patch that fixes a regression which was introduced by one of my recent commits (spotted by Dominique). My first impulse to fix the spurious error was to check for the 'intrinsic' attribute, however it is actually not set (yet?) in resolve_fl_derived, so the next-best thing is to check for 'use_assoc'. That is probably even better, since it's more general. Obviously, if a type has the 'use_assoc' attribute, then it has been declared in another module, so there is no need to complain that it was not declared. The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk? Cheers, Janus diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c386a649583..8dad9d35eaf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-09-03 Janus Weil + + PR fortran/87172 + * resolve.c (resolve_fl_derived): If a type has the 'use_assoc' + attribute, then it was declared in another module, so there should be + no error that it has not been declared. + 2018-08-31 Paul Thomas PR fortran/86328 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index ded27624283..ea0ce800743 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -14245,7 +14245,7 @@ resolve_fl_derived (gfc_symbol *sym) &sym->declared_at)) return false; - if (sym->components == NULL && !sym->attr.zero_comp) + if (sym->components == NULL && !sym->attr.zero_comp && !sym->attr.use_assoc) { gfc_error ("Derived type %qs at %L has not been declared", sym->name, &sym->declared_at); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b44c714d7d2..da267de64ef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-03 Janus Weil + + PR fortran/87172 + * gfortran.dg/iso_c_binding_only_2.f90: New test case. + 2018-09-03 Richard Biener PR tree-optimization/87200 diff --git a/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90 b/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90 new file mode 100644 index 00000000000..03fafe3f5cb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! +! PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782 +! +! Contributed by Dominique d'Humieres + +module m1 + use iso_c_binding, only: c_funptr +end module + +module m2 + use m1 + use iso_c_binding +end module