It's an error to call offsetof on a non-POD type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70595 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index bf9947a..3442cc1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4761,6 +4761,13 @@
// Get the decl corresponding to this.
RecordDecl *RD = RC->getDecl();
+ if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
+ if (!CRD->isPOD())
+ return ExprError(Diag(BuiltinLoc, diag::err_offsetof_non_pod_type)
+ << SourceRange(CompPtr[0].LocStart, OC.LocEnd)
+ << Res->getType());
+ }
+
FieldDecl *MemberDecl
= dyn_cast_or_null<FieldDecl>(LookupQualifiedName(RD, OC.U.IdentInfo,
LookupMemberName)