From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1403 invoked by alias); 6 Dec 2007 10:48:14 -0000 Received: (qmail 1389 invoked by uid 22791); 6 Dec 2007 10:48:13 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 06 Dec 2007 10:48:07 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lB6Ajs9C018112; Thu, 6 Dec 2007 05:45:54 -0500 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [10.10.36.72]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB6AjrG8001227; Thu, 6 Dec 2007 05:45:53 -0500 Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id lB6Ajr8D002493; Thu, 6 Dec 2007 05:45:53 -0500 Received: (from jakub@localhost) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11/Submit) id lB6AjrFt002491; Thu, 6 Dec 2007 05:45:53 -0500 Date: Thu, 06 Dec 2007 10:48:00 -0000 From: Jakub Jelinek To: Mark Mitchell Cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [C++ PATCH] Fix -frepo (PR c++/34178, take 2) Message-ID: <20071206104553.GG25112@devserv.devel.redhat.com> Reply-To: Jakub Jelinek References: <20071127215831.GX16835@devserv.devel.redhat.com> <20071205151120.GA25112@devserv.devel.redhat.com> <47574A61.1060200@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47574A61.1060200@codesourcery.com> User-Agent: Mutt/1.4.1i X-IsSubscribed: yes 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 X-SW-Source: 2007-12/txt/msg00258.txt.bz2 On Wed, Dec 05, 2007 at 05:03:29PM -0800, Mark Mitchell wrote: > Jakub Jelinek wrote: > > > 2007-12-05 Jakub Jelinek > > > > PR c++/34178 > > * repo.c (repo_emit_p): Return 2 for > > DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P decls only if they are > > const. > > Why don't we want to use DECL_INTEGRAL_CONSTANT_VAR_P here? That's what my first patch version did. But that breaks e.g. the repo7.C testcase in http://gcc.gnu.org/ml/gcc-patches/2007-12/msg00182.html >From the #define DECL_INTEGRAL_CONSTANT_VAR_P(NODE) \ (TREE_CODE (NODE) == VAR_DECL \ && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (NODE)) \ && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (NODE)) \ && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (NODE)) conditions we already check TREE_CODE (decl) == VAR_DECL and DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) in repo.c and with this patch also CP_TYPE_CONST_P (TREE_TYPE (decl)) But in repo7.C the const static data member is aggregate, not integral or enum. finish_static_data_member has /* Force the compiler to know when an uninitialized static const member is being used. */ if (CP_TYPE_CONST_P (TREE_TYPE (decl)) && init == 0) TREE_USED (decl) = 1; Later on duplicate_decls clears DECL_EXTERNAL on this decl (because a definition was parsed) and after tsubst finish_static_data_member sets TREE_USED again. Next in instantiate_decl we call 14742 if (TREE_PUBLIC (d) && !DECL_REALLY_EXTERN (d) && !repo_emit_p (d)) on this, and with DECL_INTEGRAL_CONSTANT_VAR_P test in repo_emit_p that returns 0, which means the rest of instantiate_decl is bypassed for this decl. Then this makes into cgraph, which emits it, as the decl is !DECL_EXTERNAL, TREE_USED etc. (and even emits it without the initialized as common symbol, as DECL_INITIAL is NULL). > > * decl2.c (import_export_decl): Don't make VAR_DECLs import_p when > > flag_use_repository and repo_emit_p returned 2. > > > + if ((flag_implicit_templates > > + && !flag_use_repository) > > Shouldn't that condition involve emit_p, rather than just be > !flag_use_repository? That's not needed, we know that emit_p is 2 at this point: emit_p = repo_emit_p (decl); if (emit_p == 0) import_p = true; else if (emit_p == 1) { ... return; } if (import_p) ; else if (...) { ... } else if (DECL_TEMPLATE_INSTANTIATION (decl) || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl)) { // The && !flag_use_repository addition is here. } emit_p can be only 0, 1, 2, if it is 0, then import_p was true and so we don't hit this point, if it is 1, we returned early. Jakub