From 0f44b5a85e612e1644d688be93151b22f08604a7 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 8 Aug 2009 16:55:18 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaExpr.cpp | 2 ++ test/SemaCXX/attr-deprecated.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/SemaCXX/attr-deprecated.cpp 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}} +} -- 2.40.0