[PATCH] D46190: For an ODR declaration, set the 'Used' bit on its associated declarations.

Carlos Alberto Enciso via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 06:40:08 PDT 2018


CarlosAlbertoEnciso added a comment.

In https://reviews.llvm.org/D46190#1083502, @rsmith wrote:

> Let's look at your original example again (I've cleaned it up and extended it a bit, but hopefully this matches your intent):
>
>   namespace nsp {
>     int var1, var2;
>   }
>  
>   using nsp::var1;
>   using nsp::var2;
>  
>   void bar() {
>     nsp::var1 = 1;
>     var2 = 1;
>   }
>
>
> Now, what should happen here is:
>
> - The use of `nsp::var1` in `bar` marks `nsp::var1` as referenced (because it was named), and marks `nsp::var1` as used (because it was odr-used by the assignment). The `UsingShadowDecl` for `::var1` is not marked as referenced (nor used), so we emit an unused-using-declaration warning.
> - The use of `var2` in `bar` marks `::var2` as referenced (because it was named), and marks `nsp::var2` as used (because it was odr-used by the assignment). The `UsingShadowDecl` for `::var2` is marked as referenced, so we do not warn on it.


Your extended example matches my original intent. That is a good starting point. Now I am clear on the expected behavior.

Thanks very much for your comments.


Repository:
  rC Clang

https://reviews.llvm.org/D46190





More information about the cfe-commits mailing list