aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
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
commit57cbb141ca7ee020d6853cd098065a9e0c2d69cc (patch)
tree75c879c45c0b14b817f17d26f0f90d48cb1a5aca /lib/Sema/SemaType.cpp
parent0b1de54fd69da1424084588196883ad4c0a57a57 (diff)
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 1bdd7c3b39..ad704685e5 100644
--- a/lib/Sema/SemaType.cpp
+++ b/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();