[cfe-dev] #error and #warning: why include "#error/#warning" in the diagnostic?

Douglas Gregor dgregor at apple.com
Wed Feb 1 07:56:57 PST 2012


On Jan 31, 2012, at 10:25 PM, Ted Kremenek wrote:

> 
> On Jan 31, 2012, at 8:21 PM, Douglas Gregor wrote:
> 
>>> 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.
> 
> That seems even more verbose, and not any more clearer.
> 
>>> 
>>> 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.
> 
> We can always support another command line flag that causes us to omit the '#error' and the '#warning' in the message for clients that don't want it (which do exist) since they can use diagnostic categories.  That may seem like overkill, but we have plenty of driver flags for controlling the behavior of diagnostics.  The suggestion of having "from source directive" is just a poor man's replacement of not having good diagnostic categories on the command line (where they make less sense).

We shouldn't be introducing a flag to control a minor aspect of two related diagnostics.

	- Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120201/426cdcb1/attachment.html>


More information about the cfe-dev mailing list