]> granicus.if.org Git - clang/commitdiff
[CUDA] Print a "previous-decl" note when calling an illegal member fn.
authorJustin Lebar <jlebar@google.com>
Wed, 10 Aug 2016 01:09:18 +0000 (01:09 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 10 Aug 2016 01:09:18 +0000 (01:09 +0000)
Summary:
When we emit err_ref_bad_target, we should emit a "'method' declared
here" note.  We already do so in most places, just not in
BuildCallToMemberFunction.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23240

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

lib/Sema/SemaOverload.cpp
test/SemaCUDA/method-target.cu

index 2baf696a710d70e2f77ffd6073d69b99632ed0bb..04751d21bfa584612f29a37d27b377dde803bf17 100644 (file)
@@ -12334,6 +12334,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
         Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target)
             << IdentifyCUDATarget(Method) << Method->getIdentifier()
             << IdentifyCUDATarget(Caller);
+        Diag(Method->getLocation(), diag::note_previous_decl) << Method;
         return ExprError();
       }
     }
index 3fabfc359b7a6074c9ed5386c417b57e677e28d2..505664586bf420b6a14ef28bdc5c49ebc9e8f1f1 100644 (file)
@@ -6,7 +6,7 @@
 // Test 1: host method called from device function
 
 struct S1 {
-  void method() {}
+  void method() {} // expected-note {{'method' declared here}}
 };
 
 __device__ void foo1(S1& s) {
@@ -29,7 +29,7 @@ __device__ void foo2(S2& s, int i, float f) {
 // Test 3: device method called from host function
 
 struct S3 {
-  __device__ void method() {}
+  __device__ void method() {} // expected-note {{'method' declared here}};
 };
 
 void foo3(S3& s) {
@@ -63,7 +63,7 @@ __device__ void foo5(S5& s, S5& t) {
 // Test 6: call method through pointer
 
 struct S6 {
-  void method() {}
+  void method() {} // expected-note {{'method' declared here}};
 };
 
 __device__ void foo6(S6* s) {