[cfe-commits] [PATCH] Fix bad highlight range when diagnosing non-class friend usage

Magee, Josh Joshua.Magee at am.sony.com
Wed Aug 29 17:50:34 PDT 2012


Hi,

Attached is a patch to fix an assertion that occurs when printing diagnostic
warnings for non-class friend usage.

Example:
This case prints fine:
struct { friend int; } a;
  warning: non-class friend type 'int' is a C++11 extension [-Wc++11-extensions]
  friend int;
  ^~~~~~~~~~

This case causes an assertion:
struct {int friend; } a;
  warning: non-class friend type 'int' is a C++11 extension [-Wc++11-extensions]
...
Assertion `StartColNo <= EndColNo && "Invalid range!"' failed.

The problem is that when printing the diagnostic the possibility that the
friend specifier may appear after the type specifier is not considered.  The
fix is to check whether the friend specifier appears after the type and adjust
the highlight range accordingly.


Can someone review and, if everything is OK, commit?

Thanks!
Josh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: friend-diagnostic-fix.diff
Type: application/octet-stream
Size: 1890 bytes
Desc: friend-diagnostic-fix.diff
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120830/065d398f/attachment.obj>


More information about the cfe-commits mailing list