diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-11-16 21:31:25 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-11-16 21:31:25 +0000 |
commit | add6ab50849032b3136a0bb59916159c8c63315b (patch) | |
tree | 37e8b42cf7fc6e7a83b5777334d783c7e2ba1122 | |
parent | 732a3e0dd198a8b61d7704f878b29605ffd7a7ad (diff) | |
download | bcm5719-llvm-add6ab50849032b3136a0bb59916159c8c63315b.tar.gz bcm5719-llvm-add6ab50849032b3136a0bb59916159c8c63315b.zip |
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();
^
llvm-svn: 287154
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/enable_if.cpp | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 2e567863261..cf90a343835 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12499,9 +12499,9 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // 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(), diff --git a/clang/test/SemaCXX/enable_if.cpp b/clang/test/SemaCXX/enable_if.cpp index 81308136c48..e265b410ac8 100644 --- a/clang/test/SemaCXX/enable_if.cpp +++ b/clang/test/SemaCXX/enable_if.cpp @@ -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}} + } +} |