diff options
| author | Steve Naroff <snaroff@apple.com> | 2007-10-18 03:27:23 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2007-10-18 03:27:23 +0000 |
| commit | 8569d7734906b2e3823300cc306c44720f946135 (patch) | |
| tree | 4390445f7bda1c6112e44256b15012dbf0314b50 | |
| parent | 94977674587dabd56481c438bd4e934a43e8e80a (diff) | |
| download | bcm5719-llvm-8569d7734906b2e3823300cc306c44720f946135.tar.gz bcm5719-llvm-8569d7734906b2e3823300cc306c44720f946135.zip | |
Fix the following bug...
unsigned char asso_values[] = { 34 };
int legal2() {
return asso_values[0];
}
The code that creates the new constant array type was operating on the original type.
As a result, the constant type being generated was "unsigned char [1][]" (which is wrong).
The fix is to operate on the element type - in this case, the correct type is "unsigned char [1]"
I added this case to array-init.c, which clearly didn't catch this bogosity...
llvm-svn: 43112
| -rw-r--r-- | clang/Sema/SemaDecl.cpp | 2 | ||||
| -rw-r--r-- | clang/clang.xcodeproj/project.pbxproj | 1 | ||||
| -rw-r--r-- | clang/test/Sema/array-init.c | 5 |
3 files changed, 6 insertions, 2 deletions
diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp index 390caafdc0b..5b54d8be7db 100644 --- a/clang/Sema/SemaDecl.cpp +++ b/clang/Sema/SemaDecl.cpp @@ -472,7 +472,7 @@ bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) { // Return a new array type from the number of initializers (C99 6.7.8p22). llvm::APSInt ConstVal(32); ConstVal = numInits; - DeclType = Context.getConstantArrayType(DeclType, ConstVal, + DeclType = Context.getConstantArrayType(VAT->getElementType(), ConstVal, ArrayType::Normal, 0); } return hadError; diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index ab5c53c4075..cf39da026b6 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -745,7 +745,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c index 510a7792d13..5b22681d1b9 100644 --- a/clang/test/Sema/array-init.c +++ b/clang/test/Sema/array-init.c @@ -103,6 +103,11 @@ void legal() { }; } +unsigned char asso_values[] = { 34 }; +int legal2() { + return asso_values[0]; +} + void illegal() { short q2[4][][2] = { // expected-error{{array has incomplete element type 'short [][2]'}} { 1, 0, 0, 0, 0, 0 }, |

