]> granicus.if.org Git - clang/commitdiff
getFunctionLevelDeclContext needs to get the previous DeclContext if EnterDeclaratorC...
authorAnders Carlsson <andersca@mac.com>
Sat, 8 Aug 2009 17:48:49 +0000 (17:48 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 8 Aug 2009 17:48:49 +0000 (17:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78480 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp
test/SemaCXX/attr-deprecated.cpp

index 0259a3d18d503de1056a91f227b537593b81b1ed..b839e769691dc478b333f1169c780ef4aff8d988 100644 (file)
@@ -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();
   
index a647d8124dd88845c915f5be2d53cb5f53bf29e3..99a249e10d9f9bf421bda49617a04f223782e900 100644 (file)
@@ -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;
+}