This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix -frepo (PR c++/34178, take 2)


On Wed, Dec 05, 2007 at 05:03:29PM -0800, Mark Mitchell wrote:
> Jakub Jelinek wrote:
> 
> > 2007-12-05  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]