From patchwork Tue Jul 17 18:52:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 171540 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]) by ozlabs.org (Postfix) with SMTP id DDB6E2C0098 for ; Wed, 18 Jul 2012 04:52:25 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343155946; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=lUGgvG8 /W4/8/hHnCbbIeYmJ8do=; b=BpcDu7/0DynlIwNZdb1YdDV9TE8tr7EXXUQ06NM oFJySLjvyYXaF0Claate4iPf8j2D8KAmF+myijiv41TIEntGtDjYbgQb95Zm0/7N zo277ZHjrzuckgBtF6AJhRKsZld1LRAY6vF6y84JVSODwUorbgBEF+IM3VLH79jh YS1U= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=sDMbLE6UTrGNW6MY07dJ3nYWR98JClRQG+yZcKZxsfL61qmtXiofHFYpkn5YUM kZXsBu5D+E2rnIgjWCR8efdn6R07sIT5LO4PNE/wBWxE9blF5ROJU+ZJmcl9GReK BNTOLzSZlhFdCO+/E61Mbdl3zKYBFwPPBvqvRjLi1gVMU=; Received: (qmail 9701 invoked by alias); 17 Jul 2012 18:52:19 -0000 Received: (qmail 9684 invoked by uid 22791); 17 Jul 2012 18:52:17 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jul 2012 18:52:05 +0000 Received: from [192.168.178.22] (port-92-204-53-225.dynamic.qsc.de [92.204.53.225]) by mx01.qsc.de (Postfix) with ESMTP id 512A33D1F0; Tue, 17 Jul 2012 20:52:04 +0200 (CEST) Message-ID: <5005B454.9020608@net-b.de> Date: Tue, 17 Jul 2012 20:52:04 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Fortran, Patch] Fix #line parsing 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 gfortran properly handles the "#line" which come from #include statements and look as # 1234 "include_file_name.f90" 1 Here, the syntax is "# linenumber filename flags", where flags is a space-delimited list of the flags 1,2,3, or 4. The problem is that the gfortran didn't handle the case of having no flag. Additionally, I now also go through the new-file handling for system headers. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias PS: I didn't include a test case; one could create one using -fdump-tree-original-lineno, if you think that it makes sense. 2012-07-17 Tobias Burnus PR fortran/53993 * scanner.c (preprocessor_line): Fix parsing of a "#line" which has no flags. diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 4fad58b..df9f01d 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -1654,6 +1654,9 @@ preprocessor_line (gfc_char_t *c) gfc_file *f; int escaped, unescape; char *filename; + enum {FLAG_NEW_FILE = 1, FLAG_PREV_FILE, FLAG_SYSHEADER, FLAG_EXTERN_C}; + + /* The expected syntax is "# linenumber filename flags". */ c++; while (*c == ' ' || *c == '\t') @@ -1739,20 +1742,24 @@ preprocessor_line (gfc_char_t *c) flag[i] = true; } + /* No flag implies that one might have a new file. */ + if (!flag[FLAG_NEW_FILE] && !flag[FLAG_PREV_FILE] && !flag[FLAG_SYSHEADER]) + flag[FLAG_NEW_FILE] = true; + /* Convert the filename in wide characters into a filename in narrow characters. */ filename = gfc_widechar_to_char (wide_filename, -1); /* Interpret flags. */ - if (flag[1]) /* Starting new file. */ + if (flag[FLAG_NEW_FILE] || flag[FLAG_SYSHEADER]) /* Starting new file. */ { f = get_file (filename, LC_RENAME); add_file_change (f->filename, f->inclusion_line); current_file = f; } - if (flag[2]) /* Ending current file. */ + if (flag[FLAG_PREV_FILE]) /* Ending current file. */ { if (!current_file->up || filename_cmp (current_file->up->filename, filename) != 0)