[cfe-commits] r147023 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/PCH/chain-cxx.cpp test/SemaTemplate/instantiate-declref-ice.cpp

Enea Zaffanella zaffanella at cs.unipr.it
Mon Jan 2 13:37:25 PST 2012


Il 21/12/2011 01:25, Richard Smith ha scritto:
> Author: rsmith
> Date: Tue Dec 20 18:25:33 2011
> New Revision: 147023
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=147023&view=rev
> Log:
> C++ constant expression handling: eagerly instantiate static const integral data
> members of class templates so that their values can be used in ICEs. This
> required reverting r105465, to get such instantiated members to be included in
> serialized ASTs.

Hi Richard.

I noticed only now that your commit was reverting r105465:

> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp	2010/06/04 08:34:32	105464
> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp	2010/06/04 09:35:39	105465
> @@ -373,7 +373,8 @@
>    SemaRef.CheckVariableDeclaration(Var, Previous, Redeclaration);
>  
>    if (D->isOutOfLine()) {
> -    D->getLexicalDeclContext()->addDecl(Var);
> +    if (!D->isStaticDataMember())
> +      D->getLexicalDeclContext()->addDecl(Var);
>      Owner->makeDeclVisibleInContext(Var);
>    } else {
>      Owner->addDecl(Var);


For reference, the change in r105465 was discussed on the cfe-dev list
in this thread:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-June/009231.html

where it was agreed that "Implicit instantiations should not show up in
the translation unit context."

I understand from what you wrote above that these implicit
instantiations need to occur in the serialized AST.
Have you considered the possibility of replacing the (inline) static
member declaration inside the implicit instantiation of the class
template? This is basically what is done when instantiating out-of-line
definitions of class methods, they appear to be "inline" (but not in the
formal sense) method definition.

Enea.



More information about the cfe-commits mailing list