aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-28 18:41:37 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-28 18:41:37 +0000
commitd04b1be7d3015a307f93eea0b9ab0ecce612951e (patch)
tree8465af67623c2995f0ba593ed806d158d1891a51 /lib/Sema
parentd8307b1033ef52a1ae640691bc45052fddb07a69 (diff)
Make sure that out-of-line function and variable definitions are not
pushed into scope. Fixes PR5056. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaDecl.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d0463c658e..7f3f24efea 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -288,14 +288,22 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
((DeclContext *)S->getEntity())->isTransparentContext())
S = S->getParent();
- S->AddDecl(DeclPtrTy::make(D));
-
// Add scoped declarations into their context, so that they can be
// found later. Declarations without a context won't be inserted
// into any context.
if (AddToContext)
CurContext->addDecl(D);
+ // Out-of-line function and variable definitions should not be pushed into
+ // scope.
+ if ((isa<FunctionTemplateDecl>(D) &&
+ cast<FunctionTemplateDecl>(D)->getTemplatedDecl()->isOutOfLine()) ||
+ (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isOutOfLine()) ||
+ (isa<VarDecl>(D) && cast<VarDecl>(D)->isOutOfLine()))
+ return;
+
+ S->AddDecl(DeclPtrTy::make(D));
+
// C++ [basic.scope]p4:
// -- exactly one declaration shall declare a class name or
// enumeration name that is not a typedef name and the other