[cfe-commits] [PATCH] Re: [cfe-dev] Interest in a -Wusing-namespace-in-headers?

Nico Weber thakis at chromium.org
Sat Apr 2 12:49:58 PDT 2011


On Sat, Apr 2, 2011 at 9:51 AM, Nico Weber <thakis at chromium.org> wrote:
> Hi Elliot,
>
> thanks for this feature! It looks like it warns about the following:
>
> $ cat test.h
> namespace foo {}
> #define USE_NAMESPACE using namespace foo;
> $ cat test.cc
> #include "test.h"
>
> USE_NAMESPACE
> $ clang -c test.cc -Wheader-hygiene
> test.cc:3:1: warning: using namespace directive in global context in
> header [-Wheader-hygiene]
> USE_NAMESPACE
> ^
> In file included from test.cc:1:
> ./test.h:2:39: note: instantiated from:
> #define USE_NAMESPACE using namespace foo;
>                                      ^
> 1 warning generated.
>
> That seems wrong. This pattern is used by ICU.

I tried to fix this in r128780.

>
> Nico
>
> On Sat, Mar 26, 2011 at 3:29 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>
>> On Mar 25, 2011, at 7:30 PM, Elliot Glaysher (Chromium) wrote:
>>
>>> On Fri, Mar 25, 2011 at 9:40 AM, Peter Collingbourne <peter at pcc.me.uk> wrote:
>>>> I believe the correct thing to do is to iterate through
>>>> declaration context parents until you reach something that is not a
>>>> LinkageSpecDecl, and warn if it is a TranslationUnitDecl.
>>>
>>> Is something like the attached closer to what you want? This new
>>> version recursively walks up the DeclContext chain, and I've
>>> integrated all the examples I've seen in this thread into the tests.
>>
>> Committed in r128352, thanks!
>>
>>        - Doug
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>




More information about the cfe-commits mailing list