From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9307 invoked by alias); 28 Jan 2014 13:20:14 -0000 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 Received: (qmail 9286 invoked by uid 89); 28 Jan 2014 13:20:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2014 13:20:07 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0SDK1ii027064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Jan 2014 08:20:01 -0500 Received: from localhost (ovpn-116-72.ams2.redhat.com [10.36.116.72]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0SDJxg1007591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Jan 2014 08:20:00 -0500 Received: by localhost (Postfix, from userid 1000) id 50BD51632F2; Tue, 28 Jan 2014 14:19:57 +0100 (CET) From: Dodji Seketeli To: Markus Trippelsdorf Cc: Jakub Jelinek , Bernd Edlinger , GCC Patches , Tom Tromey , Manuel =?utf-8?B?TMOzcGV6LUliw6HDsWV6?= Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals References: <878uwt63e2.fsf@redhat.com> <20131113081610.GH27813@tucnak.zalov.cz> <87zjp7t73c.fsf@redhat.com> <87vbxcig8t.fsf@redhat.com> <20140124150532.GB396@x4> <87iot9qtff.fsf@redhat.com> <20140124154419.GQ892@tucnak.redhat.com> <878uu5qs3q.fsf@redhat.com> <20140124230239.GH396@x4> <20140124232038.GI396@x4> X-URL: http://www.redhat.com Date: Tue, 28 Jan 2014 13:20:00 -0000 In-Reply-To: <20140124232038.GI396@x4> (Markus Trippelsdorf's message of "Sat, 25 Jan 2014 00:20:38 +0100") Message-ID: <87d2jc2qgy.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-01/txt/msg01779.txt.bz2 Here is the patch I am committing right now. gcc/ChangeLog * input.c (location_get_source_line): Bail out on when line number is zero, and test the return value of lookup_or_add_file_to_cache_tab. gcc/testsuite/ChangeLog * c-c++-common/cpp/warning-zero-location.c: New test. * c-c++-common/cpp/warning-zero-location-2.c: Likewise. diff --git a/gcc/input.c b/gcc/input.c index 547c177..63cd062 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -698,7 +698,13 @@ location_get_source_line (expanded_location xloc, static char *buffer; static ssize_t len; - fcache * c = lookup_or_add_file_to_cache_tab (xloc.file); + if (xloc.line == 0) + return NULL; + + fcache *c = lookup_or_add_file_to_cache_tab (xloc.file); + if (c == NULL) + return NULL; + bool read = read_line_num (c, xloc.line, &buffer, &len); if (read && line_len) diff --git a/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c b/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c new file mode 100644 index 0000000..c0e0bf7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c @@ -0,0 +1,10 @@ +/* + { dg-options "-D _GNU_SOURCE -fdiagnostics-show-caret" } + { dg-do compile } + */ + +#line 4636 "configure" +#include +int main() { return 0; } + +/* { dg-error "No such file or directory" { target *-*-* } 4636 } */ diff --git a/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c b/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c new file mode 100644 index 0000000..ca2e102 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c @@ -0,0 +1,8 @@ +/* + { dg-options "-D _GNU_SOURCE -fdiagnostics-show-caret" } + { dg-do compile } + */ + +#define _GNU_SOURCE /* { dg-warning "redefined" } */ + +/* { dg-message "" "#define _GNU_SOURCE" {target *-*-* } 0 } -- Dodji