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

Ted Kremenek kremenek at apple.com
Wed Feb 1 08:35:56 PST 2012


On Feb 1, 2012, at 7:56 AM, Douglas Gregor wrote:

> 
> 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
> 

Why?  We have flags for controlling the depth of macro stacks in text diagnostics.  How is this any different?

More generally, I can see different clients wanting to control the diagnostic output of the compiler.  We can look for a general solution here; e.g., a single flag that can control various diagnostic options.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120201/e60ba099/attachment.html>


More information about the cfe-dev mailing list