[cfe-dev] #error and #warning: why include "#error/#warning" in the diagnostic?
dgregor at apple.com
Tue Jan 31 20:21:52 PST 2012
On Jan 31, 2012, at 6:10 PM, Chandler Carruth wrote:
> On Tue, Jan 31, 2012 at 6:00 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Sent from my iPhone
> On Jan 31, 2012, at 1:39 PM, Eric Christopher <echristo at apple.com> wrote:
> > On Jan 31, 2012, at 12:35 PM, Ted Kremenek wrote:
> >> On Jan 31, 2012, at 12:29 PM, Dmitri Gribenko wrote:
> >>> On Tue, Jan 31, 2012 at 10:17 PM, Ted Kremenek <kremenek at apple.com> wrote:
> >>>> I received some feedback from some users who wondered why #error/#warning diagnostics include the actual "#error" in the diagnostic, e.g.:
> >>>> t.c:1:2: error: #error this is an error
> >>>> This seems redundant. Is this necessary?
> >>> It marks explicitly diagnostics that come from source code (as opposed
> >>> to diagnostics coming from the compiler).
> >> That seems fine for text output, but for other clients (e.g., IDEs) we have diagnostic categories that could provide the same functionality with a much better experience.
> > True, no ideas how to do that though. Distinguishing between "compile error because the code is wrong" and "compile error because of a #error" is at least reasonably important I think.
> But the caret location makes it blindingly obvious that this came from a #error or #warning. We don't need the diagnostic text to remind us a second time.
> Sure, but not everyone has the caret diagnostics turned on.
They're not getting the full benefit of Clang's diagnostics, and they'll have far bigger problems than deciding whether Clang generated the error the user code generated the error. For example, when we complain that a + b + c + d has a type error in +, they have no clue which + we're talking about (and that's by design).
> It seems nice to distinguish in the text where the actual text comes from. That said, it just seems nice-to-have, not super important.
> Certainly "#error" seems like a pretty lame way to do this. ;] My initial thought would be:
> foo.cc:42:13: error: (from source directive) this code requires widget to be defined
> or some variant thereof.
> Among other nice things is that then the message is the same between #error and #warning, and only the level changes. The downside I see is that it's more verbose.
That's a step up from "#error", but I still find it unnecessary.
> Some (obvious) alternatives
> foo.cc:42:13: error: source directive: ...
> foo.cc:42:13: error: ... [directive]
> foo.cc:42:13: error: ... [-Wdirective] (do we even have a flag for these?)
> Someone else can probably come up with a nicer way to phrase this than I can...
I'm totally not digging the "-Wdirective"; it's too subtle.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev