summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-01-22 00:28:27 +0000
committerJohn McCall <rjmccall@apple.com>2010-01-22 00:28:27 +0000
commit7a9813ced7455b8a33a807489ca77a4f809c8a73 (patch)
tree1d7a59209cade7ea47c40c8dd2d644876290e250 /lib/Sema/SemaDecl.cpp
parentf45b646244705410866d62f1d8bf017a047ed662 (diff)
downloadclang-7a9813ced7455b8a33a807489ca77a4f809c8a73.tar.gz
clang-7a9813ced7455b8a33a807489ca77a4f809c8a73.tar.bz2
clang-7a9813ced7455b8a33a807489ca77a4f809c8a73.tar.xz
Create function, block, and template parameters in the context of the
translation unit. This is temporary for function and block parameters; template parameters can just stay this way, since Templates aren't DeclContexts. This gives us the nice property that everything created in a record DC should have access in C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94122 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index b6b3b5bee1..c2fa892603 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2864,7 +2864,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Synthesize a parameter for each argument type.
for (FunctionProtoType::arg_type_iterator AI = FT->arg_type_begin(),
AE = FT->arg_type_end(); AI != AE; ++AI) {
- ParmVarDecl *Param = ParmVarDecl::Create(Context, DC,
+ ParmVarDecl *Param = ParmVarDecl::Create(Context, NewFD,
SourceLocation(), 0,
*AI, /*TInfo=*/0,
VarDecl::None, 0);
@@ -3862,8 +3862,13 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
QualType T = adjustParameterType(parmDeclType);
+ // Temporarily put parameter variables in the translation unit, not
+ // the enclosing context. This prevents them from accidentally
+ // looking like class members in C++.
+ DeclContext *DC = Context.getTranslationUnitDecl();
+
ParmVarDecl *New
- = ParmVarDecl::Create(Context, CurContext, D.getIdentifierLoc(), II,
+ = ParmVarDecl::Create(Context, DC, D.getIdentifierLoc(), II,
T, TInfo, StorageClass, 0);
if (D.isInvalidType())