summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-18 20:28:46 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-18 20:28:46 +0000
commitaa64b7e0a85fabf9dbc7de15abd801837746b6a2 (patch)
tree0c104b411b51e5deb11deeb55536740d4d906223 /clang/lib/Sema/SemaInit.cpp
parent22361bf422a3d38fddaf88e3312bb9084a21ba37 (diff)
downloadbcm5719-llvm-aa64b7e0a85fabf9dbc7de15abd801837746b6a2.tar.gz
bcm5719-llvm-aa64b7e0a85fabf9dbc7de15abd801837746b6a2.zip
Support initialization of incomplete array with zero size (as
extension). llvm-svn: 54946
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7c48a110b2b..12ca3820dd4 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -257,19 +257,18 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
}
if (DeclType->isIncompleteArrayType()) {
// If this is an incomplete array type, the actual type needs to
- // be calculated here
+ // be calculated here.
if (numElements == 0) {
- // Sizing an array implicitly to zero is not allowed
- // (It could in theory be allowed, but it doesn't really matter.)
+ // Sizing an array implicitly to zero is not allowed by ISO C,
+ // but is supported by GNU.
SemaRef->Diag(IList->getLocStart(),
- diag::err_at_least_one_initializer_needed_to_size_array);
- hadError = true;
- } else {
- llvm::APSInt ConstVal(32);
- ConstVal = numElements;
- DeclType = SemaRef->Context.getConstantArrayType(elementType, ConstVal,
- ArrayType::Normal, 0);
+ diag::ext_typecheck_zero_array_size);
}
+
+ llvm::APSInt ConstVal(32);
+ ConstVal = numElements;
+ DeclType = SemaRef->Context.getConstantArrayType(elementType, ConstVal,
+ ArrayType::Normal, 0);
}
}
OpenPOWER on IntegriCloud