[cfe-dev] Interest in a -Wusing-namespace-in-headers?
Douglas Gregor
dgregor at apple.com
Wed Mar 16 15:33:01 PDT 2011
On Mar 16, 2011, at 3:19 PM, Elliot Glaysher (Chromium) wrote:
> Attached is a in-progress patch for a -Wusing-namespace-in-headers.
> I'm not sure if this is something people would be interested in. If
> there is, I'll continue working on this.
Seems like a reasonable opt-in warning. Are there other constructs that we should warn about in headers? If so, should they be grouped under the same warning flag?
> I do have two questions though:
>
> 1) How exactly should I be ordering the definitions in the .td files?
> Is what I did fine?
That's fine.
> 2) The tests that I wrote as is don't work. The warning gets emitted,
> but the test harness doesn't expect it despite the comment. I assume
> this is because FindExpectedDiags() in DiagChecker.cpp explicitly only
> looks in the main file for expected-* diagnostics. Is there any simple
> way to fix this? Since the purpose of the warning is to trigger only
> when not in the main file, I'll need to fix this somehow before I
> submit this for real review...
There's no good way around this, but there is a hack: FindExpectedDiags() only looks at the line number, so you can put the using directive on line 17 of the header, and put the corresponding expected-warning on line 17 of the .cpp file, and it'll work.
I'd prefer if the warning referred to these entities as "using directives" (both for the warning flag and in the text), since that's the term the standard uses.
- Doug
More information about the cfe-dev
mailing list