From patchwork Wed Mar 14 20:46:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 146717 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 3AB0BB6EE6 for ; Thu, 15 Mar 2012 07:50:10 +1100 (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=1332363011; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=zYLeBOy NO+SVcCnJb0GImcpTbf4=; b=kEH5AAkddH1fpS7N+jgMlIFLJbgPSakuDUHUfVF hy03sKWttRFUTlU6ak55h+ZA7/lom1KS3432N4+W9N7tVE9qvBapVnc8uEpFrese Zv7ji5W0mVG/PlA5X2Glxw3RcdC8F2AajRAy4z+b/pecS/Nm7EzRQyudo9uzc7MK vUvc= 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:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=bIGoCFGbZriHpegd1AzFBt0f+TOyoE3ynrIJ8y9KiRdfPZUqNOPG6NCXcl7Yac YXskTXJ8fnZRRKo2Rrnap54FV9eNvzCbqEvwvanxkOYc9QKmhSdjQ7q31XHRWYJg topf0WnyfiJ2ouxVkncPmmyFWDhoeJDma6xYbB7HjnmJc=; Received: (qmail 25887 invoked by alias); 14 Mar 2012 20:50:03 -0000 Received: (qmail 25807 invoked by uid 22791); 14 Mar 2012 20:50:00 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, TW_CX X-Spam-Check-By: sourceware.org Received: from smtp208.alice.it (HELO smtp208.alice.it) (82.57.200.104) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Mar 2012 20:49:43 +0000 Received: from [192.168.1.4] (79.25.197.187) by smtp208.alice.it (8.6.023.02) id 4F056E8507EEF181; Wed, 14 Mar 2012 21:49:41 +0100 Message-ID: <4F6103C3.7040408@oracle.com> Date: Wed, 14 Mar 2012 21:46:59 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill , manu@gcc.gnu.org Subject: [C++ Patch] PR 44783 X-IsSubscribed: yes 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 Hi, Manuel provided this patchlet improving his template instantiation notes work to use a template_backtrace_limit parameter, as requested in c++/44783. I booted and tested it on x86_64-linux. Is it Ok for mainline? Anything else we want to do here? Thanks, Paolo. /////////////////// /c-family 2012-03-14 Manuel López-Ibáñez PR c++/44783 * c.opt (ftemplate-backtrace-limit) Add. /cp 2012-03-14 Manuel López-Ibáñez PR c++/44783 * error.c (print_instantiation_partial_context): Use template_backtrace_limit. /doc 2012-03-14 Manuel López-Ibáñez PR c++/44783 * doc/invoke.texi [C++ Language Options]: Document -ftemplate-backtrace-limit. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 185392) +++ doc/invoke.texi (working copy) @@ -192,7 +192,8 @@ in the following sections. -fno-nonansi-builtins -fnothrow-opt -fno-operator-names @gol -fno-optional-diags -fpermissive @gol -fno-pretty-templates @gol --frepo -fno-rtti -fstats -ftemplate-depth=@var{n} @gol +-frepo -fno-rtti -fstats -ftemplate-backtrace-limit=@var{n} @gol +-ftemplate-depth=@var{n} @gol -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol -fno-default-inline -fvisibility-inlines-hidden @gol -fvisibility-ms-compat @gol @@ -2124,6 +2125,11 @@ represented in the minimum number of bits needed t enumerators). This assumption may not be valid if the program uses a cast to convert an arbitrary integer value to the enumerated type. +@item -ftemplate-backtrace-limit=@var{n} +@opindex ftemplate-backtrace-limit +Set the maximum number of template instantiation notes for a single +warning or error to @var{n}. The default value is 10. + @item -ftemplate-depth=@var{n} @opindex ftemplate-depth Set the maximum instantiation depth for template classes to @var{n}. Index: c-family/c.opt =================================================================== --- c-family/c.opt (revision 185392) +++ c-family/c.opt (working copy) @@ -1035,6 +1035,10 @@ ftabstop= C ObjC C++ ObjC++ Joined RejectNegative UInteger -ftabstop= Distance between tab stops for column reporting +ftemplate-backtrace-limit= +C++ ObjC++ Joined RejectNegative UInteger Var(template_backtrace_limit) Init(10) +Set the maximum number of template instantiation notes for a single warning or error + ftemplate-depth- C++ ObjC++ Joined RejectNegative Undocumented Alias(ftemplate-depth=) Index: cp/error.c =================================================================== --- cp/error.c (revision 185392) +++ cp/error.c (working copy) @@ -3076,10 +3076,20 @@ print_instantiation_partial_context (diagnostic_co t = t0; - if (n_total >= 12) + if (template_backtrace_limit + && n_total > template_backtrace_limit) { - int skip = n_total - 10; - for (n = 0; n < 5; n++) + int skip = n_total - template_backtrace_limit; + int head = template_backtrace_limit / 2; + + /* Avoid skipping just 1. If so, skip 2. */ + if (skip == 1) + { + skip = 2; + head = (template_backtrace_limit - 1) / 2; + } + + for (n = 0; n < head; n++) { gcc_assert (t != NULL); if (loc != t->locus) @@ -3088,17 +3098,19 @@ print_instantiation_partial_context (diagnostic_co loc = t->locus; t = t->next; } - if (t != NULL && skip > 1) + if (t != NULL && skip > 0) { expanded_location xloc; xloc = expand_location (loc); if (context->show_column) pp_verbatim (context->printer, - _("%s:%d:%d: [ skipping %d instantiation contexts ]\n"), + _("%s:%d:%d: [ skipping %d instantiation contexts, " + "use -ftemplate-backtrace-limit=0 to disable ]\n"), xloc.file, xloc.line, xloc.column, skip); else pp_verbatim (context->printer, - _("%s:%d: [ skipping %d instantiation contexts ]\n"), + _("%s:%d: [ skipping %d instantiation contexts, " + "use -ftemplate-backtrace-limit=0 to disable ]\n"), xloc.file, xloc.line, skip); do {