diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-08 17:48:49 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-08 17:48:49 +0000 |
commit | fb7ef75a28af7b6a7f666df2a5db53cf90d957b1 (patch) | |
tree | 293347783307d8920f8ca2a4b42195d5036f915a | |
parent | 8517d9b731f065cdfc55ec0f3ddf5d564d988648 (diff) |
getFunctionLevelDeclContext needs to get the previous DeclContext if EnterDeclaratorContext has been called. Fixes PR4694. (Doug, please review)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78480 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/Sema.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/attr-deprecated.cpp | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 0259a3d18d..b839e76969 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -310,7 +310,8 @@ void Sema::ActOnEndOfTranslationUnit() { //===----------------------------------------------------------------------===// DeclContext *Sema::getFunctionLevelDeclContext() { - DeclContext *DC = CurContext; + DeclContext *DC = PreDeclaratorDC ? PreDeclaratorDC : CurContext; + while (isa<BlockDecl>(DC)) DC = DC->getParent(); diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp index a647d8124d..99a249e10d 100644 --- a/test/SemaCXX/attr-deprecated.cpp +++ b/test/SemaCXX/attr-deprecated.cpp @@ -2,6 +2,7 @@ class A { void f() __attribute__((deprecated)); void g(A* a); + void h(A* a) __attribute__((deprecated)); int b __attribute__((deprecated)); }; @@ -14,3 +15,12 @@ void A::g(A* a) (void)b; // expected-warning{{'b' is deprecated}} (void)a->b; // expected-warning{{'b' is deprecated}} } + +void A::h(A* a) +{ + f(); + a->f(); + + (void)b; + (void)a->b; +} |