diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-13 23:31:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-13 23:31:04 +0000 |
commit | 0476d069e394fec587858985ddee870360aec1ee (patch) | |
tree | 49febc5aec69871d253b5bd5daf92db6ca8e6ce2 /clang/lib/Sema/SemaExpr.cpp | |
parent | b1027a480ac3d0545681e06b94012c95413b2116 (diff) | |
download | bcm5719-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/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index bd54681b7e0..a561b045f9a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -635,8 +635,10 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak) Cleanup.setExprNeedsCleanups(true); - Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E, nullptr, - VK_RValue); + // C++ [conv.lval]p3: + // If T is cv std::nullptr_t, the result is a null pointer constant. + CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue; + Res = ImplicitCastExpr::Create(Context, T, CK, E, nullptr, VK_RValue); // C11 6.3.2.1p2: // ... if the lvalue has atomic type, the value has the non-atomic version |