diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-25 13:49:22 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-25 13:49:22 +0000 |
commit | e0f832bd4f502e337cc9dbf826ddb5a3df8a933e (patch) | |
tree | 52264e828aaa73e802cdf0d710676f672eb1e281 /clang/lib/Sema/SemaInit.cpp | |
parent | 85f5497c4a300b2ab3182cb9ec94fac9a1f52151 (diff) | |
download | bcm5719-llvm-e0f832bd4f502e337cc9dbf826ddb5a3df8a933e.tar.gz bcm5719-llvm-e0f832bd4f502e337cc9dbf826ddb5a3df8a933e.zip |
Diagnose implicit init list for empty aggregate, like struct {}. Fixes
PR2151 (by not creating the empty implicit init list).
llvm-svn: 51556
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 35dda28d4ad..6eb072eebaf 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -57,6 +57,13 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList, else assert(0 && "CheckImplicitInitList(): Illegal type"); + if (maxElements == 0) { + SemaRef->Diag(ParentIList->getInit(Index)->getLocStart(), + diag::err_implicit_empty_initializer); + hadError = true; + return; + } + // Check the element types *before* we create the implicit init list; // otherwise, we might end up taking the wrong number of elements unsigned NewIndex = Index; |