diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-02 05:18:44 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-02 05:18:44 +0000 |
| commit | a21ad8058a8189bfde375f68a6d04f37df0e8460 (patch) | |
| tree | bafa8ad703cd80d71e1d92fde67aeb0d19c0f81d /clang/lib/Sema/SemaExpr.cpp | |
| parent | 2c71d5151353887c74af9ecbf4aa83b66114252f (diff) | |
| download | bcm5719-llvm-a21ad8058a8189bfde375f68a6d04f37df0e8460.tar.gz bcm5719-llvm-a21ad8058a8189bfde375f68a6d04f37df0e8460.zip | |
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.
llvm-svn: 49078
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f57ad2df9c7..1cd23522e8f 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -932,18 +932,8 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { } if (Ty->isFunctionType()) ImpCastExprToType(E, Context.getPointerType(Ty)); - else if (const ArrayType *ArrayTy = Ty->getAsArrayType()) { - // Make sure we don't lose qualifiers when dealing with typedefs. Example: - // typedef int arr[10]; - // void test2() { - // const arr b; - // b[4] = 1; - // } - QualType ELT = ArrayTy->getElementType(); - // FIXME: Handle ASQualType - ELT = ELT.getQualifiedType(Ty.getCVRQualifiers()|ELT.getCVRQualifiers()); - ImpCastExprToType(E, Context.getPointerType(ELT)); - } + else if (Ty->isArrayType()) + ImpCastExprToType(E, Context.getArrayDecayedType(Ty)); } /// UsualUnaryConversions - Performs various conversions that are common to most |

