summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-07 20:03:16 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-07 20:03:16 +0000
commitda776f9a8ed641a78196ef77c41449d3b3603eb8 (patch)
tree470bb8d563a4cd81d4440d60012b923192560a51 /clang/lib/Sema
parent0370597620574589473ef19571013bf65c11503f (diff)
downloadbcm5719-llvm-da776f9a8ed641a78196ef77c41449d3b3603eb8.tar.gz
bcm5719-llvm-da776f9a8ed641a78196ef77c41449d3b3603eb8.zip
Use the C++11 POD definition in C++11 mode to determine whether one
can create a VLA of class type. Fixes <rdar://problem/12151822>. llvm-svn: 171783
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaType.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1bdd7c3b398..ad704685e58 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1269,6 +1269,12 @@ static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal) {
S.LangOpts.GNUMode).isInvalid();
}
+/// \brief Determine whether the given type is a POD or standard-layout type,
+/// as appropriate for the C++ language options.
+static bool isPODType(QualType T, ASTContext &Context) {
+ return Context.getLangOpts().CPlusPlus11? T.isCXX11PODType(Context)
+ : T.isCXX98PODType(Context);
+}
/// \brief Build an array type.
///
@@ -1442,8 +1448,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
// Prohibit the use of non-POD types in VLAs.
QualType BaseT = Context.getBaseElementType(T);
if (!T->isDependentType() &&
- !BaseT.isPODType(Context) &&
- !BaseT->isObjCLifetimeType()) {
+ !BaseT->isObjCLifetimeType() &&
+ !isPODType(BaseT, Context)) {
Diag(Loc, diag::err_vla_non_pod)
<< BaseT;
return QualType();
OpenPOWER on IntegriCloud