From patchwork Mon Nov 11 21:54:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1193162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513003-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="v9+cx8N3"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="NIP4ysvb"; 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 47Bl5l1d96z9sPK for ; Tue, 12 Nov 2019 08:54: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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=m1AiGdrLhb6WImWI4g8oPbM/r4TEb9NsaZdfiUafZEfhMJ EVcXvlASs+AztFNvFeZcn3ND7TlQ118L8aHMbPKmLt101eM18XFAOKij1LrCmIhU wp+4fzX+3QDjzVD+MKfhGtsKXJ6PSB3tieZejKA6rpo/gXP7gm4ksVoEL9ix0= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=/J0TdhEigA62EZYIqZW+QH3OFC0=; b=v9+cx8N3BVcHGETGx0Ko 4wXf9MNObrkTe2sLcGheJr5SolV0+Jn78ZWmbWqcTdGKUFpANEKeDWHyR+insMZ2 HiuNODrXlTPIaHI3dQQCjkanJvFw5jjNukpqCpcEfy4KrzcKPMWlVtvGxjheoNHr oiYeMLq6V55t17FU7M4g0CY= Received: (qmail 88888 invoked by alias); 11 Nov 2019 21:54:25 -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 88872 invoked by uid 89); 11 Nov 2019 21:54:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=qualified, Reading, reporting, H*u:i686 X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Nov 2019 21:54:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1573509259; bh=lMRDaYArR6O05fVZd4VUDNMkptoCuICfC9Ra45LhseU=; h=X-UI-Sender-Class:Date:From:To:Subject; b=NIP4ysvbMc9BQgREzr7WcN2vqJblKl5TR4UTjBgkM2Y3VnsGGKbu9D+Xv2glskSrp fu1M8pGsM+rq1ixQ+mBUjVJeI7sso0tmJT/4ZUpTn0wCbor/IuSgQql90ob+WKSWnw JnlMLFtMvpcA2FbYeGH5Gx3wuImkds5T17CMsITE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from proton.at.home ([79.251.13.54]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N5G9n-1hmwd41moH-011AsI; Mon, 11 Nov 2019 22:54:19 +0100 Message-ID: <5DC9D884.4070004@gmx.de> Date: Mon, 11 Nov 2019 22:54:12 +0100 From: Harald Anlauf User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gfortran , gcc-patches Subject: [Patch, RFC] PR81651/Fortran - Enhancement request: have f951 print out fully qualified module file name Dear all, the attached patch prints the fully qualified path if an error occurs during module read. E.g., instead of a less helpful error message, pr81651.f90:2:6: 2 | use netcdf | 1 Fatal Error: File 'netcdf.mod' opened at (1) is not a GNU Fortran module file gfortran will print pr81651.f90:2:7: 2 | use netcdf | 1 Fatal Error: File '/opt/pgi/pkg/netcdf/include/netcdf.mod' opened at (1) is not a GNU Fortran module file Regtested on x86_64-pc-linux-gnu. I couldn't think of a sensible test for the testsuite, thus no testcase provided. OK for trunk? Thanks, Harald 2019-11-11 Harald Anlauf PR fortran/81651 * module.c (gzopen_included_file, gzopen_included_file_1) (gzopen_intrinsic_module, bad_module, gfc_use_module): Use fully qualified module path for error reporting. Index: gcc/fortran/module.c =================================================================== --- gcc/fortran/module.c (revision 278064) +++ gcc/fortran/module.c (working copy) @@ -187,6 +187,8 @@ /* The gzFile for the module we're reading or writing. */ static gzFile module_fp; +/* Fully qualified module path */ +static char *module_fullpath = NULL; /* The name of the module we're reading (USE'ing) or writing. */ static const char *module_name; @@ -1101,6 +1103,8 @@ if (gfc_cpp_makedep ()) gfc_cpp_add_dep (fullname, system); + free (module_fullpath); + module_fullpath = xstrdup (fullname); return f; } } @@ -1116,8 +1120,14 @@ if (IS_ABSOLUTE_PATH (name) || include_cwd) { f = gzopen (name, "r"); - if (f && gfc_cpp_makedep ()) - gfc_cpp_add_dep (name, false); + if (f) + { + if (gfc_cpp_makedep ()) + gfc_cpp_add_dep (name, false); + + free (module_fullpath); + module_fullpath = xstrdup (name); + } } if (!f) @@ -1134,8 +1144,14 @@ if (IS_ABSOLUTE_PATH (name)) { f = gzopen (name, "r"); - if (f && gfc_cpp_makedep ()) - gfc_cpp_add_dep (name, true); + if (f) + { + if (gfc_cpp_makedep ()) + gfc_cpp_add_dep (name, true); + + free (module_fullpath); + module_fullpath = xstrdup (name); + } } if (!f) @@ -1181,7 +1197,7 @@ { case IO_INPUT: gfc_fatal_error ("Reading module %qs at line %d column %d: %s", - module_name, module_line, module_column, msgid); + module_fullpath, module_line, module_column, msgid); break; case IO_OUTPUT: gfc_fatal_error ("Writing module %qs at line %d column %d: %s", @@ -7141,7 +7157,7 @@ if ((start == 1 && strcmp (atom_name, "GFORTRAN") != 0) || (start == 2 && strcmp (atom_name, " module") != 0)) gfc_fatal_error ("File %qs opened at %C is not a GNU Fortran" - " module file", filename); + " module file", module_fullpath); if (start == 3) { if (strcmp (atom_name, " version") != 0 @@ -7150,7 +7166,7 @@ || strcmp (atom_string, MOD_VERSION)) gfc_fatal_error ("Cannot read module file %qs opened at %C," " because it was created by a different" - " version of GNU Fortran", filename); + " version of GNU Fortran", module_fullpath); free (atom_string); }