Omitted declaration

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Omitted declaration

Abramo Bagnara-2
template <typename T>
struct S {
};

// S<int> v;

template struct S<int>;

Uncommenting the line above the ClassTemplateSpecializationDecl related
to the last line disappears from declarations available inside
TranslationUnitDecl.

I don't think it's expected, right?
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

Sebastian Redl
Abramo Bagnara wrote:

> template <typename T>
> struct S {
> };
>
> // S<int> v;
>
> template struct S<int>;
>
> Uncommenting the line above the ClassTemplateSpecializationDecl related
> to the last line disappears from declarations available inside
> TranslationUnitDecl.
>
> I don't think it's expected, right?
>  
If it silently disappears, no. If it also complains, then I wouldn't be
surprised.

Isn't there something about explicit instantiations and implicit
instantiations not mixing?

Sebastian
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

Douglas Gregor
In reply to this post by Abramo Bagnara-2

On May 29, 2010, at 1:02 AM, Abramo Bagnara wrote:

> template <typename T>
> struct S {
> };
>
> // S<int> v;
>
> template struct S<int>;
>
> Uncommenting the line above the ClassTemplateSpecializationDecl related
> to the last line disappears from declarations available inside
> TranslationUnitDecl.
>
> I don't think it's expected, right?


It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

Abramo Bagnara-2
Il 29/05/2010 18:31, Douglas Gregor ha scritto:

>
> On May 29, 2010, at 1:02 AM, Abramo Bagnara wrote:
>
>> template <typename T>
>> struct S {
>> };
>>
>> // S<int> v;
>>
>> template struct S<int>;
>>
>> Uncommenting the line above the ClassTemplateSpecializationDecl related
>> to the last line disappears from declarations available inside
>> TranslationUnitDecl.
>>
>> I don't think it's expected, right?
>
>
> It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.
>
Unfortunately not so easy... we have found this code rather mess...
complex ;-)

However I've attached the patch for your review/approval.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

ClassTemplate-ExplicitInst-3.patch (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

Abramo Bagnara-2
Il 05/06/2010 18:44, Abramo Bagnara ha scritto:

> Il 29/05/2010 18:31, Douglas Gregor ha scritto:
>>
>> On May 29, 2010, at 1:02 AM, Abramo Bagnara wrote:
>>
>>> template <typename T>
>>> struct S {
>>> };
>>>
>>> // S<int> v;
>>>
>>> template struct S<int>;
>>>
>>> Uncommenting the line above the ClassTemplateSpecializationDecl related
>>> to the last line disappears from declarations available inside
>>> TranslationUnitDecl.
>>>
>>> I don't think it's expected, right?
>>
>>
>> It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.
>>
>
> Unfortunately not so easy... we have found this code rather mess...
> complex ;-)
>
> However I've attached the patch for your review/approval.

Sorry to annoy you, but we have other patches to submit and, you know,
patches life outside current svn tree is a bit... dangerous.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

John McCall

On Jun 9, 2010, at 12:52 AM, Abramo Bagnara wrote:

> Il 05/06/2010 18:44, Abramo Bagnara ha scritto:
>> Il 29/05/2010 18:31, Douglas Gregor ha scritto:
>>>
>>> On May 29, 2010, at 1:02 AM, Abramo Bagnara wrote:
>>>
>>>> template <typename T>
>>>> struct S {
>>>> };
>>>>
>>>> // S<int> v;
>>>>
>>>> template struct S<int>;
>>>>
>>>> Uncommenting the line above the ClassTemplateSpecializationDecl related
>>>> to the last line disappears from declarations available inside
>>>> TranslationUnitDecl.
>>>>
>>>> I don't think it's expected, right?
>>>
>>>
>>> It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.
>>>
>>
>> Unfortunately not so easy... we have found this code rather mess...
>> complex ;-)
>>
>> However I've attached the patch for your review/approval.
>
> Sorry to annoy you, but we have other patches to submit and, you know,
> patches life outside current svn tree is a bit... dangerous.

This looks okay to me.

John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Omitted declaration

Abramo Bagnara-2
Il 12/06/2010 03:58, John McCall ha scritto:

>
> On Jun 9, 2010, at 12:52 AM, Abramo Bagnara wrote:
>
>> Il 05/06/2010 18:44, Abramo Bagnara ha scritto:
>>> Il 29/05/2010 18:31, Douglas Gregor ha scritto:
>>>>
>>>> On May 29, 2010, at 1:02 AM, Abramo Bagnara wrote:
>>>>
>>>>> template <typename T>
>>>>> struct S {
>>>>> };
>>>>>
>>>>> // S<int> v;
>>>>>
>>>>> template struct S<int>;
>>>>>
>>>>> Uncommenting the line above the ClassTemplateSpecializationDecl related
>>>>> to the last line disappears from declarations available inside
>>>>> TranslationUnitDecl.
>>>>>
>>>>> I don't think it's expected, right?
>>>>
>>>>
>>>> It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.
>>>>
>>>
>>> Unfortunately not so easy... we have found this code rather mess...
>>> complex ;-)
>>>
>>> However I've attached the patch for your review/approval.
>>
>> Sorry to annoy you, but we have other patches to submit and, you know,
>> patches life outside current svn tree is a bit... dangerous.
>
> This looks okay to me.

Commited in r105880.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev