]> granicus.if.org Git - clang/commitdiff
UnresolvedMemberExpr should have an expr location of the member (not the base)
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 3 Jun 2013 19:46:44 +0000 (19:46 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 3 Jun 2013 19:46:44 +0000 (19:46 +0000)
This matches the behavior of MemberExpr and makes diagnostics such as
"reference to non-static member function must be called" more legible in
the case that the base & member are split over multiple lines (prior to
this change the diagnostic would point to the base, not the member -
making it very unclear in chained multi-line builder-style calls)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183149 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExprCXX.h
test/SemaCXX/overloaded-operator.cpp

index a2259903efc6fffe14aa3945ac9cb37486d4caab..42fc117fb4b2fd0f15f9d4a44ae240472487e3f2 100644 (file)
@@ -3387,6 +3387,10 @@ public:
   // expression refers to.
   SourceLocation getMemberLoc() const { return getNameLoc(); }
 
+  // \brief Return the preferred location (the member name) for the arrow when
+  // diagnosing a problem with this expression.
+  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
   SourceLocation getLocStart() const LLVM_READONLY {
     if (!isImplicitAccess())
       return Base->getLocStart();
index e5b3fab33c8cabe2637e74763b2a5d64fb62f8d9..d794850a3920d0cefb0dea6115d6f149d22aacb4 100644 (file)
@@ -396,7 +396,8 @@ namespace rdar9136502 {
   };
 
   void f(X x, Y y) {
-    y << x.i; // expected-error{{reference to non-static member function must be called}}
+    y << x
+      .i; // expected-error{{reference to non-static member function must be called}}
   }
 }