[cfe-commits] r80446 - in /cfe/trunk: lib/AST/DeclCXX.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-member-initializers.cpp

Eli Friedman eli.friedman at gmail.com
Sat Aug 29 17:40:26 PDT 2009


On Sat, Aug 29, 2009 at 5:35 PM, Fariborz Jahanian<fjahanian at apple.com> wrote:
>
> On Aug 29, 2009, at 4:00 PM, Eli Friedman wrote:
>
>> On Sat, Aug 29, 2009 at 3:53 PM, Fariborz Jahanian<fjahanian at apple.com>
>> wrote:
>>>
>>> Not knowing enough about instantiation, I assume that at instantiation
>>> time,
>>> the base initializer list is rescanned with actual types and the AST for
>>> the
>>> initializer
>>> list is built from scratch. So, I am wondering why this change was
>>> necessary? Unless it
>>> caused a crash and this patch is avoiding it!
>>
>> The issue was that the initializer was getting dropped.
>
> Sorry, I wasn't clear. We are building BaseOrMemberInitializers AST for the
> CXXConstructorDecl node. Can't we just punt altogether if there is a
> dependent base
> (or field) to be initialized by constructor's initializer list. I assume
> BaseOrMemberInitializers will (can) be
> rebuilt from scratch when we instantiate the class template. Unless
> instantiation assumes the existence
> of BaseOrMemberInitializers (which  was incomplete without your patch).  My
> point is like a CFG discussion
> a while back. Why do we build something for templates which must be rebuilt
> for each instantiation?

We have to build the node because otherwise, there isn't anywhere in
the AST for the initializers to live.  In the dependent case, yes, we
could skip all analysis; if we did that, though, we would miss a class
of errors which could be detected earlier, specifically the case where
a member that requires an initializer doesn't have one.

-Eli




More information about the cfe-commits mailing list