[cfe-commits] r43112 - in /cfe/trunk: Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj test/Sema/array-init.c
Steve Naroff
snaroff at apple.com
Wed Oct 17 20:27:24 PDT 2007
Author: snaroff
Date: Wed Oct 17 22:27:23 2007
New Revision: 43112
URL: http://llvm.org/viewvc/llvm-project?rev=43112&view=rev
Log:
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...
Modified:
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/test/Sema/array-init.c
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=43112&r1=43111&r2=43112&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Wed Oct 17 22:27:23 2007
@@ -472,7 +472,7 @@
// 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;
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43112&r1=43111&r2=43112&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Oct 17 22:27:23 2007
@@ -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 = "";
Modified: cfe/trunk/test/Sema/array-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/array-init.c?rev=43112&r1=43111&r2=43112&view=diff
==============================================================================
--- cfe/trunk/test/Sema/array-init.c (original)
+++ cfe/trunk/test/Sema/array-init.c Wed Oct 17 22:27:23 2007
@@ -103,6 +103,11 @@
};
}
+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 },
More information about the cfe-commits
mailing list