From 61226d3fcf2c9b734f02c9ffa93b0e29c070e224 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 13 May 2011 01:05:07 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d99230b..ea2b2d1 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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()) - return ConstantInit && cast(Record->getDecl())->isPOD(); + return ConstantInit && + cast(Record->getDecl())->isPOD() && + !cast(Record->getDecl())->hasMutableFields(); } return true; -- cgit v1.1