summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-14 03:18:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-14 03:18:53 +0000
commit11a846ab53790ba7b8d9642e7bc4eeab8c05df88 (patch)
treec8f8cd0c4768c71fa7d0467f608267ee879d9a1d /clang/lib/Sema/SemaDecl.cpp
parent2f0eff102ce613c1b5a83b6130ee5aa6d71a5ace (diff)
downloadbcm5719-llvm-11a846ab53790ba7b8d9642e7bc4eeab8c05df88.tar.gz
bcm5719-llvm-11a846ab53790ba7b8d9642e7bc4eeab8c05df88.zip
Fixes for a couple of things:
- Declaration context of ParmVarDecls (that we got from the Declarator) was not their containing function. - C++ out-of-line method definitions didn't get an access specifier. Both were exposed by a crash when emitting a C++ method to a PCH file (assert at Decl::CheckAccessDeclContext()). llvm-svn: 75597
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3ce11570feb..c1dcdd6ec03 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2298,8 +2298,12 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Diag(Param->getLocation(), diag::err_param_typedef_of_void);
// FIXME: Leaks decl?
} else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) {
- for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
- Params.push_back(FTI.ArgInfo[i].Param.getAs<ParmVarDecl>());
+ for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
+ ParmVarDecl *Param = FTI.ArgInfo[i].Param.getAs<ParmVarDecl>();
+ assert(Param->getDeclContext() != NewFD && "Was set before ?");
+ Param->setDeclContext(NewFD);
+ Params.push_back(Param);
+ }
}
} else if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) {
@@ -2546,8 +2550,11 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
if (FunctionTemplateDecl *OldTemplateDecl
= dyn_cast<FunctionTemplateDecl>(OldDecl))
NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
- else
+ else {
+ if (isa<CXXMethodDecl>(NewFD)) // Set access for out-of-line definitions
+ NewFD->setAccess(OldDecl->getAccess());
NewFD->setPreviousDeclaration(cast<FunctionDecl>(OldDecl));
+ }
}
}
OpenPOWER on IntegriCloud