[cfe-dev] __declspec(selectany): adding an attribute to a declvar
Douglas Gregor
dgregor at apple.com
Tue Nov 30 10:50:41 PST 2010
On Nov 30, 2010, at 10:49 AM, Eric Niebler wrote:
> On 11/30/2010 1:06 PM, Douglas Gregor wrote:
>> On Nov 30, 2010, at 10:01 AM, Eric Niebler wrote:
>>> I need to be able to handle cases where the "extern" appears on a
>>> forward declaration, like this:
>>>
>>> extern const int x4;
>>> const __declspec(selectany) int x4=4;
>>>
>>> If I check the storage class in Sema::ProcessDeclAttributeList, it
>>> doesn't show up as extern in this case. I need to check the storage
>>> class somewhere else. Any ideas where?
>>
>> If you are looking for the presence of the "extern" keyword specifically, you can walk the chain of previous declarations with getPreviousDeclaration() and check for the "extern" storage class.
>
> Tried that. It doesn't work because the declaration chain isn't set up
> until MergeVarDecl gets called, which is later. Blech.
Yeah, some attributes will have to have their well-formedness checked after declaration merging.
- Doug
More information about the cfe-dev
mailing list