From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3145 invoked by alias); 29 Jul 2012 09:25:07 -0000 Received: (qmail 3104 invoked by uid 22791); 29 Jul 2012 09:25:05 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Jul 2012 09:24:51 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id C780512A44; Sun, 29 Jul 2012 11:24:49 +0200 (CEST) Received: from [192.168.0.108] (xdsl-78-35-131-249.netcologne.de [78.35.131.249]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id 740A811D96; Sun, 29 Jul 2012 11:24:48 +0200 (CEST) Message-ID: <5015015F.6070303@netcologne.de> Date: Sun, 29 Jul 2012 12:00:00 -0000 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120601 Thunderbird/13.0 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran] Fix PR 54033, problems with -I, with test cases References: <50117B5D.8030304@netcologne.de> <50118A67.2040702@mentor.com> <5012F4AF.7050807@netcologne.de> <50130F9B.1010300@mentor.com> In-Reply-To: <50130F9B.1010300@mentor.com> Content-Type: multipart/mixed; boundary="------------060905080709000002000404" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-07/txt/msg01445.txt.bz2 This is a multi-part message in MIME format. --------------060905080709000002000404 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Content-length: 727 Hello world, here is an updated patch for PR 54033, this time with test cases. Thanks to Janis for pointing me in the right direction with these. Regression-tested. OK for trunk? Thomas 2012-07-29 Thomas König PR fortran/54033 * scanner.c (add_path_to_list): Emit warning if an error occurs for an include path, if it is not present or if it is not a directory. Do not add the path in these cases. 2012-07-29 Thomas König PR fortran/54033 * gfortran.dg/include_6.f90: New test case. * gfortran.dg/include_7.f90: New test case. * gfortran.dg/include_3.f90: Add dg-warning for missing directory. --------------060905080709000002000404 Content-Type: text/x-fortran; name="include_6.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="include_6.f90" Content-length: 121 ! { dg-do compile } ! { dg-options "-I gfortran.log" } ! { dg-warning "is not a directory" "" { target *-*-* } 0 } end --------------060905080709000002000404 Content-Type: text/x-fortran; name="include_7.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="include_7.f90" Content-length: 144 ! { dg-do compile } ! { dg-options "-I nothere" } ! { dg-warning "Nonexistent include directory" "missing directory" { target *-*-* } 0 } end --------------060905080709000002000404 Content-Type: text/x-patch; name="p3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p3.diff" Content-length: 1343 Index: fortran/scanner.c =================================================================== --- fortran/scanner.c (Revision 189754) +++ fortran/scanner.c (Arbeitskopie) @@ -311,12 +311,30 @@ add_path_to_list (gfc_directorylist **list, const { gfc_directorylist *dir; const char *p; - + struct stat st; + p = path; while (*p == ' ' || *p == '\t') /* someone might do "-I include" */ if (*p++ == '\0') return; + if (stat (p, &st)) + { + if (errno != ENOENT) + gfc_warning_now ("Include directory \"%s\": %s", path, + xstrerror(errno)); + else + /* FIXME: Also support -Wmissing-include-dirs. */ + gfc_warning_now ("Nonexistent include directory \"%s\"", path); + return; + } + + else if (!S_ISDIR (st.st_mode)) + { + gfc_warning_now ("\"%s\" is not a directory", path); + return; + } + if (head || *list == NULL) { dir = XCNEW (gfc_directorylist); Index: testsuite/gfortran.dg/include_3.f95 =================================================================== --- testsuite/gfortran.dg/include_3.f95 (Revision 189754) +++ testsuite/gfortran.dg/include_3.f95 (Arbeitskopie) @@ -24,3 +24,4 @@ end function ! { dg-do compile } ! { dg-options "-fpreprocessed -g3" } +! { dg-warning "Nonexistent include directory" "missing directory" { target *-*-* } 0 } --------------060905080709000002000404--