summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-11-05 19:47:47 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-11-05 19:47:47 +0000
commit1060067dd11ae11cc637d9d3c50eb9407dca514b (patch)
tree1c0bbdc5e4d00e9cab1e4885f6d050cb574202aa /clang/lib/Sema/SemaDecl.cpp
parent415c64ea3f621212180ba8b04909fdfc3c51309a (diff)
downloadbcm5719-llvm-1060067dd11ae11cc637d9d3c50eb9407dca514b.tar.gz
bcm5719-llvm-1060067dd11ae11cc637d9d3c50eb9407dca514b.zip
Don't allow definitions of array variables without some size information in C++. Fixed PR5401
llvm-svn: 86165
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d89cb5fc97f..088c7dc7807 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3433,6 +3433,16 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
return;
}
+ // An array without size is an incomplete type, and there are no special
+ // rules in C++ to make such a definition acceptable.
+ if (getLangOptions().CPlusPlus && Type->isIncompleteArrayType() &&
+ !Var->hasExternalStorage()) {
+ Diag(Var->getLocation(),
+ diag::err_typecheck_incomplete_array_needs_initializer);
+ Var->setInvalidDecl();
+ return;
+ }
+
// C++ [temp.expl.spec]p15:
// An explicit specialization of a static data member of a template is a
// definition if the declaration includes an initializer; otherwise, it
OpenPOWER on IntegriCloud