[cfe-dev] __declspec(selectany): adding an attribute to a declvar
Eric Niebler
eric at boostpro.com
Tue Nov 30 10:49:42 PST 2010
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.
> Or, more likely, it's a question of external linkage, in which case you'll want to use NamedDecl::getLinkage() to check for external linkage.
Yeah, prolly.
--
Eric Niebler
BoostPro Computing
http://www.boostpro.com
More information about the cfe-dev
mailing list