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

Douglas Gregor dgregor at apple.com
Wed Feb 1 08:46:49 PST 2012


On Feb 1, 2012, at 8:35 AM, Ted Kremenek wrote:

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

*That* is a general flag that affects every diagnostic Clang can emit. It controls a formatting policy. 

What you're proposing is a flag that tweaks the wording of two specific diagnostics. It's too narrow in scope to warrant a special flag.

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


Options that control general policies (color, word-wrapping, macro/template depth, carets, Fix-Its, ranges) all make sense. Options that tweak the wording of specific diagnostics don't, because it's not a useful thing for a user to think about ("oh, I *would* like that diagnostic to have a slightly different wording. let me go modify my build settingsā€¦") and because this solution just doesn't scale if we start resolving "what's the best wording?" discussions by adding a flag.

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


More information about the cfe-dev mailing list