diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-09 03:29:58 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-09 03:29:58 +0000 |
| commit | 5a294e6a2c116010f8cb88a5e020b30888e8c642 (patch) | |
| tree | f0c8b2f750712f1c9b444df2771b84bf1952f6af /clang/lib/CodeGen/CGDecl.cpp | |
| parent | 3bc84198f409707849974f8b512cea3a6e62d850 (diff) | |
| download | bcm5719-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.cpp | 14 |
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. |

