diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-24 17:48:14 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-24 17:48:14 +0000 |
commit | 12757ab4cb49f64071d1cd8d6a186c9a975721fa (patch) | |
tree | aa1d6ff97a5d5a7928a7135183d8c850717b47fd /clang/lib/CodeGen | |
parent | 46975ea682f4414ad2bcbee4d8c1ad7835354ec6 (diff) | |
download | bcm5719-llvm-12757ab4cb49f64071d1cd8d6a186c9a975721fa.tar.gz bcm5719-llvm-12757ab4cb49f64071d1cd8d6a186c9a975721fa.zip |
Treat list-initialization of scalars as a first-class citizen in C++11.
Allow empty initializer lists for scalars, which mean value-initialization.
Constant evaluation for single-element and empty initializer lists for scalars.
Codegen for empty initializer lists for scalars.
Test case comes in next commit.
llvm-svn: 140459
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 264a71403ab..c2f871334f8 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -837,9 +837,14 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { llvm::VectorType *VType = dyn_cast<llvm::VectorType>(ConvertType(E->getType())); - // We have a scalar in braces. Just use the first element. - if (!VType) + if (!VType) { + if (NumInitElements == 0) { + // C++11 value-initialization for the scalar. + return EmitNullValue(E->getType()); + } + // We have a scalar in braces. Just use the first element. return Visit(E->getInit(0)); + } unsigned ResElts = VType->getNumElements(); |