summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2018-12-14 22:22:29 +0000
committerErich Keane <erich.keane@intel.com>2018-12-14 22:22:29 +0000
commit07325c80d9bc8060ac1e7dceabeecfcb141146bf (patch)
treec0a0f136dbf9f6b978c9e70e5501f5562f7259b3 /clang/lib/Sema/SemaInit.cpp
parent574d737e06fb9efc53b196536b3bf2124219d7e0 (diff)
downloadbcm5719-llvm-07325c80d9bc8060ac1e7dceabeecfcb141146bf.tar.gz
bcm5719-llvm-07325c80d9bc8060ac1e7dceabeecfcb141146bf.zip
Add extension to always default-initialize nullptr_t.
Core issue 1013 suggests that having an uninitialied std::nullptr_t be UB is a bit foolish, since there is only a single valid value. This DR reports that DR616 fixes it, which does so by making lvalue-to-rvalue conversions from nullptr_t be equal to nullptr. However, just implementing that results in warnings/etc in many places. In order to fix all situations where nullptr_t would seem uninitialized, this patch instead (as an otherwise transparent extension) default initializes uninitialized VarDecls of nullptr_t. Differential Revision: https://reviews.llvm.org/D53713 Change-Id: I84d72a9290054fa55341e8cbdac43c8e7f25b885 llvm-svn: 349201
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index c2f14229d8d..57277f6e829 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4881,6 +4881,13 @@ static void TryDefaultInitialization(Sema &S,
return;
}
+ // As an extension, and to fix Core issue 1013, zero initialize nullptr_t.
+ // Since there is only 1 valid value of nullptr_t, we can just use that.
+ if (DestType->isNullPtrType()) {
+ Sequence.AddZeroInitializationStep(Entity.getType());
+ return;
+ }
+
// - otherwise, no initialization is performed.
// If a program calls for the default initialization of an object of
OpenPOWER on IntegriCloud