[cfe-commits] PATCH: Make common negative array size diagnostics include the declarator name

Douglas Gregor dgregor at apple.com
Mon Jan 3 17:57:11 PST 2011


On Jan 3, 2011, at 5:44 PM, Chandler Carruth wrote:

> The idea is that people have code simulating static_assert with a preprocessor macro and a template that declares a negatively sized array. Commonly, the variable name will be passed in from the macro to form the "user error message" such as it may be. Currently, Clang doesn't include this name in the diagnostic text, which is usually fine because the source code is displayed with a caret diagnostic immediately following the diagnostic. However, this can fall down in several ways: turning caret diagnostics off, or when the variable name is on a different line from any of those quoted in the caret diagnostics.
> 
> The fix is simple, if a bit crude. Suggestions on better wording or other places where this would be useful are welcome.
> 
> I've included one test that actually checks the functionality of the patch. There are a bunch of mechanical test updates that will accompany it on submit.

In cases where there is no entity name, I presume that we get a fairly lame diagnostic like:

  error: '' declared as an array with a negative size

I'd much rather that we have two forms of the diagnostic: one when the entity has a name (using your new text), and one when the entity has no nice name (e.g., because it's an abstract declarator).

Otherwise, LGTM.

  - Doug





More information about the cfe-commits mailing list