r188920 - Fix the end sourcelocation of the call expression in a member access when

Nick Lewycky nicholas at mxc.ca
Wed Aug 21 12:09:45 PDT 2013


Author: nicholas
Date: Wed Aug 21 14:09:44 2013
New Revision: 188920

URL: http://llvm.org/viewvc/llvm-project?rev=188920&view=rev
Log:
Fix the end sourcelocation of the call expression in a member access when
recovering by adding empty parenthesis. Fixes PR16676!

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/test/SemaCXX/member-expr.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=188920&r1=188919&r2=188920&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Aug 21 14:09:44 2013
@@ -1306,8 +1306,7 @@ bool Sema::tryToRecoverWithCall(ExprResu
     // arguments and that it returns something of a reasonable type,
     // so we can emit a fixit and carry on pretending that E was
     // actually a CallExpr.
-    SourceLocation ParenInsertionLoc =
-      PP.getLocForEndOfToken(Range.getEnd());
+    SourceLocation ParenInsertionLoc = PP.getLocForEndOfToken(Range.getEnd());
     Diag(Loc, PD)
       << /*zero-arg*/ 1 << Range
       << (IsCallableWithAppend(E.get())
@@ -1317,8 +1316,8 @@ bool Sema::tryToRecoverWithCall(ExprResu
 
     // FIXME: Try this before emitting the fixit, and suppress diagnostics
     // while doing so.
-    E = ActOnCallExpr(0, E.take(), ParenInsertionLoc,
-                      None, ParenInsertionLoc.getLocWithOffset(1));
+    E = ActOnCallExpr(0, E.take(), Range.getEnd(), None,
+                      Range.getEnd().getLocWithOffset(1));
     return true;
   }
 

Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=188920&r1=188919&r2=188920&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Wed Aug 21 14:09:44 2013
@@ -214,3 +214,13 @@ namespace PR15045 {
     call_func(f);  // expected-note {{in instantiation of function template specialization 'PR15045::call_func<PR15045::foo>' requested here}}
   }
 }
+
+namespace pr16676 {
+  struct S { int i; };
+  struct T { S* get_s(); };
+  int f(S* s) {
+    T t;
+    return t.get_s  // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+        .i;  // expected-error {{member reference type 'pr16676::S *' is a pointer; maybe you meant to use '->'}}
+  }
+}





More information about the cfe-commits mailing list