aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-08 16:55:18 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-08 16:55:18 +0000
commit0f44b5a85e612e1644d688be93151b22f08604a7 (patch)
tree3e03389833e376621facf438757cd0fe038c0d3e
parent2aa944463a282c0a9d6c68fa7cb7bb3184b833f4 (diff)
Make sure to diagnose use of declarations in the case where we create an implicit CXXThisExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78474 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--test/SemaCXX/attr-deprecated.cpp16
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5d9b69c844..cec1aeafac 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1139,6 +1139,8 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
MarkDeclarationReferenced(Loc, D);
if (PerformObjectMemberConversion(This, D))
return ExprError();
+ if (DiagnoseUseOfDecl(D, Loc))
+ return ExprError();
return Owned(new (Context) MemberExpr(This, true, D,
Loc, MemberType));
}
diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp
new file mode 100644
index 0000000000..a647d8124d
--- /dev/null
+++ b/test/SemaCXX/attr-deprecated.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-cc %s -verify -fsyntax-only
+class A {
+ void f() __attribute__((deprecated));
+ void g(A* a);
+
+ int b __attribute__((deprecated));
+};
+
+void A::g(A* a)
+{
+ f(); // expected-warning{{'f' is deprecated}}
+ a->f(); // expected-warning{{'f' is deprecated}}
+
+ (void)b; // expected-warning{{'b' is deprecated}}
+ (void)a->b; // expected-warning{{'b' is deprecated}}
+}