summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-13 23:31:04 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-13 23:31:04 +0000
commit0476d069e394fec587858985ddee870360aec1ee (patch)
tree49febc5aec69871d253b5bd5daf92db6ca8e6ce2 /clang/lib/AST/Expr.cpp
parentb1027a480ac3d0545681e06b94012c95413b2116 (diff)
downloadbcm5719-llvm-0476d069e394fec587858985ddee870360aec1ee.tar.gz
bcm5719-llvm-0476d069e394fec587858985ddee870360aec1ee.zip
PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type
nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r345562, reverted in r346065, now that CodeGen's handling of non-odr-used variables has been fixed. llvm-svn: 363337
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 77d444151c3..72e1119851b 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1885,6 +1885,11 @@ ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T,
ExprValueKind VK) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ // Per C++ [conv.lval]p3, lvalue-to-rvalue conversions on class and
+ // std::nullptr_t have special semantics not captured by CK_LValueToRValue.
+ assert((Kind != CK_LValueToRValue ||
+ !(T->isNullPtrType() || T->getAsCXXRecordDecl())) &&
+ "invalid type for lvalue-to-rvalue conversion");
ImplicitCastExpr *E =
new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, VK);
if (PathSize)
OpenPOWER on IntegriCloud