summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-09 03:29:58 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-09 03:29:58 +0000
commit5a294e6a2c116010f8cb88a5e020b30888e8c642 (patch)
treef0c8b2f750712f1c9b444df2771b84bf1952f6af /clang/lib/CodeGen/CGDecl.cpp
parent3bc84198f409707849974f8b512cea3a6e62d850 (diff)
downloadbcm5719-llvm-5a294e6a2c116010f8cb88a5e020b30888e8c642.tar.gz
bcm5719-llvm-5a294e6a2c116010f8cb88a5e020b30888e8c642.zip
CWG issue 1405: mutable members are allowed in literal types, but can't undergo
lvalue-to-rvalue conversions in constant expressions. llvm-svn: 150145
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 82f7fed7bae..3d32091a4b0 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -773,11 +773,15 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
// emit it as a global instead.
if (CGM.getCodeGenOpts().MergeAllConstants && Ty.isConstQualified() &&
!NRVO && !isByRef && Ty->isLiteralType()) {
- EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage);
-
- emission.Address = 0; // signal this condition to later callbacks
- assert(emission.wasEmittedAsGlobal());
- return emission;
+ CXXRecordDecl *RD =
+ Ty->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
+ if (!RD || !RD->hasMutableFields()) {
+ EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage);
+
+ emission.Address = 0; // signal this condition to later callbacks
+ assert(emission.wasEmittedAsGlobal());
+ return emission;
+ }
}
// Otherwise, tell the initialization code that we're in this case.
OpenPOWER on IntegriCloud