diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-20 05:25:56 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-20 05:25:56 +0000 |
commit | d8dc2100487640d8f5ce53201fdcfac7b5ca32b2 (patch) | |
tree | 4e15fd4ae7ace9569f5796e34f5c2b7018aef4c6 /lib/Sema/SemaInit.cpp | |
parent | 6223c2237052dc99cc5263d4cf20cb0bff7650cd (diff) |
Be a bit more defensive in SemaInit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51301 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index d5378d30d5..20fa50731d 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -111,7 +111,8 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T, diag::err_excess_initializers_in_char_array_initializer, IList->getInit(Index)->getSourceRange()); hadError = true; - } else { + } else if (!T->isIncompleteType()) { + // Don't warn for incomplete types, since we'll get an error elsewhere SemaRef->Diag(IList->getInit(Index)->getLocStart(), diag::warn_excess_initializers, IList->getInit(Index)->getSourceRange()); @@ -137,6 +138,11 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList, CheckArrayType(IList, DeclType, Index); else assert(0 && "Aggregate that isn't a function or array?!"); + } else if (DeclType->isVoidType()) { + // This is clearly invalid, so not much we can do here. Don't bother + // with a diagnostic; we'll give an error elsewhere. + Index++; + hadError = true; } else { // In C, all types are either scalars or aggregates, but // additional handling is needed here for C++ (and possibly others?). |