From patchwork Tue Sep 28 15:21:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 65980 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 A2238B712D for ; Wed, 29 Sep 2010 01:21:34 +1000 (EST) Received: (qmail 7638 invoked by alias); 28 Sep 2010 15:21:32 -0000 Received: (qmail 7627 invoked by uid 22791); 28 Sep 2010 15:21:31 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Sep 2010 15:21:26 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id EEFE793717; Tue, 28 Sep 2010 17:21:23 +0200 (CEST) Date: Tue, 28 Sep 2010 17:21:23 +0200 (CEST) From: Richard Guenther To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Make C++ use TRANSLATION_UNIT_DECL for global entities In-Reply-To: <4CA20504.1090703@redhat.com> Message-ID: References: <4CA1F826.7080801@redhat.com> <4CA20504.1090703@redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 On Tue, 28 Sep 2010, Jason Merrill wrote: > On 09/28/2010 10:23 AM, Richard Guenther wrote: > > then we'd push global_namespace where we previously didn't. > > Or maybe I misunderstood you? > > Right, that is what I meant. I think that pushing global_namespace there > shouldn't hurt, but it would also be fine to test against global_namespace and > just not push in that case. Ok, I'll test then. > > > > + /* Nonzero for a scope which is equal to file scope. */ > > > > + #define SCOPE_FILE_SCOPE_P(EXP) \ > > > > + (! (EXP) || TREE_CODE (EXP) == TRANSLATION_UNIT_DECL) > > > > > > Hmm, I wonder if it will be confusing that this is not true for > > > global_namespace as well. > > > > Well, these are middle-end macros supposed to be applied to > > {TYPE,DECL}_CONTEXT, not CP_{TYPE,DECL}_CONTEXT. I can > > introduce CP_ variants of them and avoid using the middle-end > > variants in the frontend if you prefer that. > > Don't bother, it isn't used enough to worry about. Ok. I'll post an updated patch after testing finished. Thanks, Richard. Index: decl.c =================================================================== --- decl.c (revision 164681) +++ decl.c (working copy) @@ -4163,16 +4164,8 @@ start_decl (const cp_declarator *declara || decl == error_mark_node) return error_mark_node; - context = DECL_CONTEXT (decl); - - if (context) - { - *pushed_scope_p = push_scope (context); - - /* We are only interested in class contexts, later. */ - if (TREE_CODE (context) == NAMESPACE_DECL) - context = NULL_TREE; - } + context = CP_DECL_CONTEXT (decl); + *pushed_scope_p = push_scope (context); if (initialized) /* Is it valid for this decl to have an initializer at all? @@ -4241,7 +4234,7 @@ start_decl (const cp_declarator *declara && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) warning (0, "inline function %q+D given attribute noinline", decl); - if (context && COMPLETE_TYPE_P (complete_type (context))) + if (TYPE_P (context) && COMPLETE_TYPE_P (complete_type (context))) { if (TREE_CODE (decl) == VAR_DECL) {