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.<div>
<br></div><div>The fix is simple, if a bit crude. Suggestions on better wording or other places where this would be useful are welcome.</div><div><br></div><div>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.</div>