From: Nick Lewycky Date: Wed, 21 Aug 2013 19:09:44 +0000 (+0000) Subject: Fix the end sourcelocation of the call expression in a member access when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f96df620402f41ce9f1a97c0d286c2b42637d5b9;p=clang Fix the end sourcelocation of the call expression in a member access when recovering by adding empty parenthesis. Fixes PR16676! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188920 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 873bfcd3f8..26f26316d1 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -1306,8 +1306,7 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, // 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(ExprResult &E, const PartialDiagnostic &PD, // 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; } diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp index cd8951f5f1..239aecff81 100644 --- a/test/SemaCXX/member-expr.cpp +++ b/test/SemaCXX/member-expr.cpp @@ -214,3 +214,13 @@ namespace PR15045 { call_func(f); // expected-note {{in instantiation of function template specialization 'PR15045::call_func' 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 '->'}} + } +}