summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-13 22:16:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-13 22:16:19 +0000
commit6331c408b5eb4ea3c645b5df04a33f70748894c4 (patch)
treefc436a0549e73b16d39200f4e46c9158ad830d35 /clang/lib/CodeGen/CGExprConstant.cpp
parent4809fc1d9df7c7de4fece44619df32f21836f341 (diff)
downloadbcm5719-llvm-6331c408b5eb4ea3c645b5df04a33f70748894c4.tar.gz
bcm5719-llvm-6331c408b5eb4ea3c645b5df04a33f70748894c4.zip
Deal with a horrible C++11 special case. If a non-literal type has a constexpr
constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index ccb4b930e67..0b3ac9cbe5c 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -939,6 +939,15 @@ llvm::Constant *CodeGenModule::EmitConstantInit(const VarDecl &D,
if (const APValue *Value = D.evaluateValue())
return EmitConstantValue(*Value, D.getType(), CGF);
+ // FIXME: Implement C++11 [basic.start.init]p2: if the initializer of a
+ // reference is a constant expression, and the reference binds to a temporary,
+ // then constant initialization is performed. ConstExprEmitter will
+ // incorrectly emit a prvalue constant in this case, and the calling code
+ // interprets that as the (pointer) value of the reference, rather than the
+ // desired value of the referee.
+ if (D.getType()->isReferenceType())
+ return 0;
+
const Expr *E = D.getInit();
assert(E && "No initializer to emit");
OpenPOWER on IntegriCloud