Author: gbiv Date: Wed Nov 16 15:31:25 2016 New Revision: 287154 URL: http://llvm.org/viewvc/llvm-project?rev=287154&view=rev Log: Use the member function location in enable_if diagnostics.
Before: <stdin>:3:3: error: no matching member function for call to 'bar' Foo().bar(); ^ After: <stdin>:3:9: error: no matching member function for call to 'bar' Foo().bar(); ^ Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCXX/enable_if.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=287154&r1=287153&r2=287154&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 16 15:31:25 2016 @@ -12499,9 +12499,9 @@ Sema::BuildCallToMemberFunction(Scope *S // In the case the method to call was not selected by the overloading // resolution process, we still need to handle the enable_if attribute. Do // that here, so it will not hide previous -- and more relevant -- errors. - if (isa<MemberExpr>(NakedMemExpr)) { + if (auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) { if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) { - Diag(MemExprE->getLocStart(), + Diag(MemE->getMemberLoc(), diag::err_ovl_no_viable_member_function_in_call) << Method << Method->getSourceRange(); Diag(Method->getLocation(), Modified: cfe/trunk/test/SemaCXX/enable_if.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=287154&r1=287153&r2=287154&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/enable_if.cpp (original) +++ cfe/trunk/test/SemaCXX/enable_if.cpp Wed Nov 16 15:31:25 2016 @@ -440,3 +440,13 @@ void testFoo() { foo(1, 0, m, 3); // expected-error{{no matching}} } } + +// Tests that we emit errors at the point of the method call, rather than the +// beginning of the expression that happens to be a member call. +namespace member_loc { + struct Foo { void bar() __attribute__((enable_if(0, ""))); }; // expected-note{{disabled}} + void testFoo() { + Foo() + .bar(); // expected-error{{no matching member function}} + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits