[cfe-dev] Sema && redefinitions

Douglas Gregor dgregor at apple.com
Fri Dec 5 10:42:11 PST 2008


On Dec 5, 2008, at 9:31 PM, Anton Korobeynikov wrote:

> Hi, Douglas
>
>> At #3, we merge the dllimport from #2 into #3, so #3 has the  
>> dllimport
>> attribute. #3's getPreviousDeclaration() link back to #2.
> The problem is that we need to separate two cases:
>
> 1.
> void foo() __attribute__((dllimport));
> void foo() {}
>
> This is legal, we need just to ignore dllimport attribute and issue  
> a warning
>
> 2. void foo() __attribute__((dllimport)) {}
>
> This is hard error.
>
> At the point, when attributes were merged, we cannot distinguish cases
> 1 and 2 and I feel pretty bad into adding something 'custom' inside
> merging logic...


Oh, that is tricky. Our ASTs can't tell those two cases apart.

To fix this, I suspect we'd want to add a bit into Attr that states  
whether this copy of the attribute was specified directly or whether  
it was propagated from a previous declaration of the same entity. We  
do something similar with default arguments of function parameters.

	- Doug



More information about the cfe-dev mailing list