From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17572 invoked by alias); 16 May 2014 15:27:02 -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 17484 invoked by uid 89); 16 May 2014 15:27:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 16 May 2014 15:27:00 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlK21-0004Vz-Qp for gcc-patches@gcc.gnu.org; Fri, 16 May 2014 11:26:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK21-0004V7-HP for gcc-patches@gcc.gnu.org; Fri, 16 May 2014 11:26:45 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFQiWo010251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 May 2014 11:26:45 -0400 Received: from barimba.redhat.com (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFQhHS022960; Fri, 16 May 2014 11:26:44 -0400 From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: Tom Tromey Subject: [PATCH 2/5] c_diagnostic_ignored_function hack Date: Fri, 16 May 2014 15:27:00 -0000 Message-Id: <1400254001-12038-3-git-send-email-tromey@redhat.com> In-Reply-To: <1400254001-12038-1-git-send-email-tromey@redhat.com> References: <1400254001-12038-1-git-send-email-tromey@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-SW-Source: 2014-05/txt/msg01288.txt.bz2 In the typical case, when compiling a snippet of user code, gdb wraps the user's text in a dummy function. It's somewhat odd for users if an error in their code is mentioned as coming from this dummy function. This patch makes it possible to suppress the function-name display in a straightforward way: it adds a new global which the plugin can set to declare the name of the dummy function. This patch seems like a bit of a hack, but there didn't seem to be a notably cleaner approach. 2014-05-16 Phil Muldoon Tom Tromey * c-lang.c (c_diagnostic_ignored_function): New global. (c_print_error_function): New function. (LANG_HOOKS_PRINT_ERROR_FUNCTION): Define. * c-lang.h (c_diagnostic_ignored_function): Declare. --- gcc/c/ChangeLog | 8 ++++++++ gcc/c/c-lang.c | 22 ++++++++++++++++++++++ gcc/c/c-lang.h | 4 ++++ 3 files changed, 34 insertions(+) diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.c index 97c0443..e563813 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.c @@ -35,6 +35,26 @@ along with GCC; see the file COPYING3. If not see enum c_language_kind c_language = clk_c; +// If non-zero, this names a function which should not be reported in +// a diagnostic. This is used by the gdb plugin to avoid showing the +// generated function name to the user. +const char *c_diagnostic_ignored_function; + +// An implementation of the print_error_function langhook that +// respects C_DIAGNOSTIC_IGNORED_FUNCTION. +static void +c_print_error_function (diagnostic_context *context, const char *file, + diagnostic_info *diagnostic) +{ + if (c_diagnostic_ignored_function != NULL + && current_function_decl != NULL_TREE + && DECL_NAME (current_function_decl) != NULL_TREE + && strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)), + c_diagnostic_ignored_function) == 0) + return; + lhd_print_error_function (context, file, diagnostic); +} + /* Lang hooks common to C and ObjC are declared in c-objc-common.h; consequently, there should be very few hooks below. */ @@ -44,6 +64,8 @@ enum c_language_kind c_language = clk_c; #define LANG_HOOKS_INIT c_objc_common_init #undef LANG_HOOKS_INIT_TS #define LANG_HOOKS_INIT_TS c_common_init_ts +#undef LANG_HOOKS_PRINT_ERROR_FUNCTION +#define LANG_HOOKS_PRINT_ERROR_FUNCTION c_print_error_function /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; diff --git a/gcc/c/c-lang.h b/gcc/c/c-lang.h index 7fcf333..022206f 100644 --- a/gcc/c/c-lang.h +++ b/gcc/c/c-lang.h @@ -59,4 +59,8 @@ struct GTY(()) language_function { attribute lists. */ extern GTY(()) int current_omp_declare_target_attribute; +/* If non-zero, the name of a function whose name should not be + reported in a diagnostic. */ +extern const char *c_diagnostic_ignored_function; + #endif /* ! GCC_C_LANG_H */ -- 1.9.0