From: Erich Keane Date: Fri, 14 Dec 2018 22:41:18 +0000 (+0000) Subject: Revert "Add extension to always default-initialize nullptr_t." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e78a7db56c2946ae84d57cdf43051ce96cc06aa;p=clang Revert "Add extension to always default-initialize nullptr_t." This reverts commit 46efdf2ccc2a80aefebf8433dbf9c7c959f6e629. Richard Smith commented just after I submitted this that this is the wrong solution. Reverting so that I can fix differently. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349206 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 57277f6e82..c2f14229d8 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -4881,13 +4881,6 @@ 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 diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index 1d913c11d3..38e099b7fb 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -125,16 +125,21 @@ struct Type { }; void shouldNotCrash() { - decltype(nullptr) p; // expected-note{{'p' initialized to a null pointer value}} + decltype(nullptr) p; // expected-note{{'p' declared without an initial value}} if (getSymbol()) // expected-note {{Assuming the condition is false}} // expected-note@-1{{Taking false branch}} - // expected-note@-2{{Assuming the condition is true}} - // expected-note@-3{{Taking true branch}} - invokeF(p); // expected-note{{Passing null pointer value via 1st parameter 'x'}} - // expected-note@-1{{Calling 'invokeF'}} + // expected-note@-2{{Assuming the condition is false}} + // expected-note@-3{{Taking false branch}} + // expected-note@-4{{Assuming the condition is true}} + // expected-note@-5{{Taking true branch}} + invokeF(p); // expected-warning{{1st function call argument is an uninitialized value}} + // expected-note@-1{{1st function call argument is an uninitialized value}} if (getSymbol()) // expected-note {{Assuming the condition is false}} // expected-note@-1{{Taking false branch}} - invokeF(nullptr); + // expected-note@-2{{Assuming the condition is true}} + // expected-note@-3{{Taking true branch}} + invokeF(nullptr); // expected-note {{Calling 'invokeF'}} + // expected-note@-1{{Passing null pointer value via 1st parameter 'x'}} if (getSymbol()) { // expected-note {{Assuming the condition is true}} // expected-note@-1{{Taking true branch}} X *xx = Type().x; // expected-note {{Null pointer value stored to field 'x'}} diff --git a/test/SemaCXX/ast-print-crash.cpp b/test/SemaCXX/ast-print-crash.cpp index 33edc34823..c108f666d7 100644 --- a/test/SemaCXX/ast-print-crash.cpp +++ b/test/SemaCXX/ast-print-crash.cpp @@ -7,6 +7,6 @@ // CHECK: struct { // CHECK-NEXT: } dont_crash_on_syntax_error; -// CHECK-NEXT: decltype(nullptr) p(/*implicit*/(decltype(nullptr))0); +// CHECK-NEXT: decltype(nullptr) p; struct { } dont_crash_on_syntax_error /* missing ; */ decltype(nullptr) p; diff --git a/test/SemaCXX/nullptr_t-init.cpp b/test/SemaCXX/nullptr_t-init.cpp deleted file mode 100644 index f7843de1bc..0000000000 --- a/test/SemaCXX/nullptr_t-init.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ffreestanding -Wuninitialized %s -// expected-no-diagnostics -typedef decltype(nullptr) nullptr_t; - -// Ensure no 'uninitialized when used here' warnings (Wuninitialized), for -// nullptr_t always-initialized extension. -nullptr_t default_init() { - nullptr_t a; - return a; -}