From ee0653963537f6ea60f655856fb0c83d7d4010db Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 20 Feb 2012 23:58:14 +0000 Subject: Make RequireLiteralType work correctly with incomplete array types. PR12037. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151005 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaType.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/Sema/SemaType.cpp') diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 9c8a68b3da..d9867fd1b0 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -4249,7 +4249,9 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, const PartialDiagnostic &PD) { assert(!T->isDependentType() && "type should not be dependent"); - RequireCompleteType(Loc, T, 0); + QualType ElemType = Context.getBaseElementType(T); + RequireCompleteType(Loc, ElemType, 0); + if (T->isLiteralType()) return false; @@ -4261,12 +4263,16 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, if (T->isVariableArrayType()) return true; - const RecordType *RT = T->getBaseElementTypeUnsafe()->getAs(); + const RecordType *RT = ElemType->getAs(); if (!RT) return true; const CXXRecordDecl *RD = cast(RT->getDecl()); + // FIXME: Better diagnostic for incomplete class? + if (!RD->isCompleteDefinition()) + return true; + // If the class has virtual base classes, then it's not an aggregate, and // cannot have any constexpr constructors or a trivial default constructor, // so is non-literal. This is better to diagnose than the resulting absence -- cgit v1.2.3-18-g5258