diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-11 00:53:35 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-11 00:53:35 +0000 |
commit | 6fa28ffd5a60ca9d3461eb8827d32e968f6f88fc (patch) | |
tree | f872c0eebdd85dc7e6b3f9f78f1df0e298122296 /clang/lib/Sema/SemaDecl.cpp | |
parent | c26e63e9868cb66339f244f199328ae2848803ef (diff) | |
download | bcm5719-llvm-6fa28ffd5a60ca9d3461eb8827d32e968f6f88fc.tar.gz bcm5719-llvm-6fa28ffd5a60ca9d3461eb8827d32e968f6f88fc.zip |
Fix "regression" caused by updating our notion of POD to better match the C++11
rules: instead of requiring flexible array members to be POD, require them to
be trivially-destructible. This seems to be the only constraint that actually
matters here (and even then, it's questionable whether this matters).
llvm-svn: 198983
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 78ead1ee92b..222211dab97 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11994,9 +11994,14 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, Diag(FD->getLocation(), diag::ext_c99_flexible_array_member) << FD->getDeclName() << Record->getTagKind(); - if (!FD->getType()->isDependentType() && - !Context.getBaseElementType(FD->getType()).isPODType(Context)) { - Diag(FD->getLocation(), diag::err_flexible_array_has_nonpod_type) + // If the element type has a non-trivial destructor, we would not + // implicitly destroy the elements, so disallow it for now. + // + // FIXME: GCC allows this. We should probably either implicitly delete + // the destructor of the containing class, or just allow this. + QualType BaseElem = Context.getBaseElementType(FD->getType()); + if (!BaseElem->isDependentType() && BaseElem.isDestructedType()) { + Diag(FD->getLocation(), diag::err_flexible_array_has_nontrivial_dtor) << FD->getDeclName() << FD->getType(); FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); |