diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 22:12:13 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 22:12:13 +0000 |
commit | f1a29dd3442304e183b0491fbe2d33f6c963069e (patch) | |
tree | 64b5defb92948be8b09a6f1b5c48ec60abad1325 /contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp | |
parent | 8a6fe8ce60ab99778558c4951d23615a0141daf0 (diff) | |
parent | 581a6d8501ff5614297da837b81ed3b6956361ea (diff) | |
download | src-f1a29dd3442304e183b0491fbe2d33f6c963069e.tar.gz src-f1a29dd3442304e183b0491fbe2d33f6c963069e.zip |
Merge llvm, clang, lld and lldb release_40 branch r292009. Also update
build glue.
Notes
Notes:
svn path=/projects/clang400-import/; revision=312197
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp index fe77c7f6f3bf..a8512b294055 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp @@ -1627,8 +1627,17 @@ static bool CheckLiteralType(EvalInfo &Info, const Expr *E, // C++1y: A constant initializer for an object o [...] may also invoke // constexpr constructors for o and its subobjects even if those objects // are of non-literal class types. - if (Info.getLangOpts().CPlusPlus14 && This && - Info.EvaluatingDecl == This->getLValueBase()) + // + // C++11 missed this detail for aggregates, so classes like this: + // struct foo_t { union { int i; volatile int j; } u; }; + // are not (obviously) initializable like so: + // __attribute__((__require_constant_initialization__)) + // static const foo_t x = {{0}}; + // because "i" is a subobject with non-literal initialization (due to the + // volatile member of the union). See: + // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677 + // Therefore, we use the C++1y behavior. + if (This && Info.EvaluatingDecl == This->getLValueBase()) return true; // Prvalue constant expressions must be of literal types. |