From patchwork Thu Dec 9 15:17:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 74907 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 6140BB7080 for ; Fri, 10 Dec 2010 02:18:00 +1100 (EST) Received: (qmail 24843 invoked by alias); 9 Dec 2010 15:17:56 -0000 Received: (qmail 24834 invoked by uid 22791); 9 Dec 2010 15:17:54 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Dec 2010 15:17:49 +0000 Received: (qmail 18089 invoked from network); 9 Dec 2010 15:17:47 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Dec 2010 15:17:47 -0000 Date: Thu, 9 Dec 2010 10:17:44 -0500 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH, c++] fix bogus complaints about translation_unit_decl in error messages Message-ID: <20101209151743.GH25904@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 When we're pretty-printing things in error messages, we now get confused by the new TRANSLATION_UNIT_DECLs added this release cycle: g++.old-deja/g++.other/overload11.C:86:13: error: no context to resolve type of '#'translation_unit_decl' not supported by dump_decl#::ovl' g++.old-deja/g++.other/overload11.C:87:14: error: no context to resolve type of '&#'translation_unit_decl' not supported by dump_decl#::ovl' g++.old-deja/g++.other/overload11.C:89:19: error: no context to resolve type of '#'translation_unit_decl' not supported by dump_decl#::ovl' g++.old-deja/g++.other/overload11.C:90:20: error: no context to resolve type of '&#'translation_unit_decl' not supported by dump_decl#::ovl' g++.dg/parse/friend5.C:6:19: error: 'void foo()' is already defined in class '#'translation_unit_decl' not supported by dump_type#' g++.dg/lookup/java1.C:67:11: error: '#'translation_unit_decl' not supported by dump_decl#::_Jv_Throw' should never be overloaded The patch below silences this checking DECL_FILE_SCOPE_P in appropriate places. I suppose it'd be nice to have testsuite logic to assert that we never complain about unsupported things in the tree dumpers... Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan * decl.c (grokmethod): Check DECL_FILE_SCOPE_P. * error.c (dump_decl) [OVERLOAD]: Check DECL_FILE_SCOPE_P. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b72b588..5735d4e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13098,7 +13098,7 @@ grokmethod (cp_decl_specifier_seq *declspecs, if (DECL_IN_AGGR_P (fndecl)) { - if (DECL_CONTEXT (fndecl) + if (!DECL_FILE_SCOPE_P (fndecl) && TREE_CODE (DECL_CONTEXT (fndecl)) != NAMESPACE_DECL) error ("%qD is already defined in class %qT", fndecl, DECL_CONTEXT (fndecl)); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 4fb47dc..f45f1c2 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1027,12 +1027,13 @@ dump_decl (tree t, int flags) dump_type (DECL_CONTEXT (t), flags); pp_cxx_colon_colon (cxx_pp); } - else if (DECL_CONTEXT (t)) + else if (DECL_FILE_SCOPE_P (t)) + dump_decl (DECL_NAME (t), flags); + else { dump_decl (DECL_CONTEXT (t), flags); pp_cxx_colon_colon (cxx_pp); } - dump_decl (DECL_NAME (t), flags); break; }