When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable fields. If so, it can't be a global constant. llvm-svn: 131276
This commit is contained in:
@@ -946,7 +946,9 @@ static bool DeclIsConstantGlobal(ASTContext &Context, const VarDecl *D,
|
||||
if (Context.getLangOptions().CPlusPlus) {
|
||||
if (const RecordType *Record
|
||||
= Context.getBaseElementType(D->getType())->getAs<RecordType>())
|
||||
return ConstantInit && cast<CXXRecordDecl>(Record->getDecl())->isPOD();
|
||||
return ConstantInit &&
|
||||
cast<CXXRecordDecl>(Record->getDecl())->isPOD() &&
|
||||
!cast<CXXRecordDecl>(Record->getDecl())->hasMutableFields();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user