diff options
| author | Douglas Gregor <dgregor@apple.com> | 2013-01-07 20:03:16 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2013-01-07 20:03:16 +0000 |
| commit | da776f9a8ed641a78196ef77c41449d3b3603eb8 (patch) | |
| tree | 470bb8d563a4cd81d4440d60012b923192560a51 /clang/lib | |
| parent | 0370597620574589473ef19571013bf65c11503f (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 10 |
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(); |

