aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-02 05:18:44 +0000
committerChris Lattner <sabre@nondot.org>2008-04-02 05:18:44 +0000
commite6327747b72bb687c948270f702ff53c30f411a6 (patch)
treebc891542f2d622dfc93dc32bad05ecf8e3b33412 /lib/Sema/SemaType.cpp
parent503d613235543c1adf7ea49fce56cffa1e65d5fb (diff)
Fix several bugs in array -> pointer decomposition.
First, we got several CVR propagation cases wrong, which Eli pointed out in PR2039. Second, we didn't propagate address space qualifiers correctly, leading to incorrect lowering of code in CodeGen/address-space.c. Third, we didn't uniformly propagate the specifier in the array to the pointer ("int[restrict 4]" -> "int *restrict"). This adds an ASTContext::getArrayDecayedType member that handles the non-trivial logic for this seemingly simple operation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index ad9d138f91..5874477de1 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -317,18 +317,17 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
// type in ParmVarDecl (which makes the code generator unhappy).
//
// FIXME: We still apparently need the conversion in
- // Sema::ParseParamDeclarator(). This doesn't make any sense, since
+ // Sema::ActOnParamDeclarator(). This doesn't make any sense, since
// it should be driving off the type being created here.
//
// FIXME: If a source translation tool needs to see the original type,
// then we need to consider storing both types somewhere...
//
- if (const ArrayType *AT = ArgTy->getAsArrayType()) {
- // int x[restrict 4] -> int *restrict
- ArgTy = Context.getPointerType(AT->getElementType());
- ArgTy = ArgTy.getQualifiedType(AT->getIndexTypeQualifier());
+ if (ArgTy->isArrayType()) {
+ ArgTy = Context.getArrayDecayedType(ArgTy);
} else if (ArgTy->isFunctionType())
ArgTy = Context.getPointerType(ArgTy);
+
// Look for 'void'. void is allowed only as a single argument to a
// function with no other parameters (C99 6.7.5.3p10). We record
// int(void) as a FunctionTypeProto with an empty argument list.
@@ -391,9 +390,9 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
assert(!ArgTy.isNull() && "Couldn't parse type?");
// Perform the default function/array conversion (C99 6.7.5.3p[7,8]).
// This matches the conversion that is done in
- // Sema::ParseParamDeclarator().
- if (const ArrayType *AT = ArgTy->getAsArrayType())
- ArgTy = Context.getPointerType(AT->getElementType());
+ // Sema::ActOnParamDeclarator().
+ if (ArgTy->isArrayType())
+ ArgTy = Context.getArrayDecayedType(ArgTy);
else if (ArgTy->isFunctionType())
ArgTy = Context.getPointerType(ArgTy);
ArgTys.push_back(ArgTy);