summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-08 17:48:49 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-08 17:48:49 +0000
commit5fd7dad784320a7dc76eb2d7aaae649d697e4f23 (patch)
treec451684039c946e73f8abc73a1fe212d67caac84
parentf6448f57e6047dd61b3cded43c531416189c0c80 (diff)
downloadbcm5719-llvm-5fd7dad784320a7dc76eb2d7aaae649d697e4f23.tar.gz
bcm5719-llvm-5fd7dad784320a7dc76eb2d7aaae649d697e4f23.zip
getFunctionLevelDeclContext needs to get the previous DeclContext if EnterDeclaratorContext has been called. Fixes PR4694. (Doug, please review)
llvm-svn: 78480
-rw-r--r--clang/lib/Sema/Sema.cpp3
-rw-r--r--clang/test/SemaCXX/attr-deprecated.cpp10
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 0259a3d18d5..b839e769691 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/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/clang/test/SemaCXX/attr-deprecated.cpp b/clang/test/SemaCXX/attr-deprecated.cpp
index a647d8124dd..99a249e10d9 100644
--- a/clang/test/SemaCXX/attr-deprecated.cpp
+++ b/clang/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;
+}
OpenPOWER on IntegriCloud