r349206 - Revert "Add extension to always default-initialize nullptr_t."
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 14 14:41:18 PST 2018
Author: erichkeane
Date: Fri Dec 14 14:41:18 2018
New Revision: 349206
URL: http://llvm.org/viewvc/llvm-project?rev=349206&view=rev
Log:
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.
Removed:
cfe/trunk/test/SemaCXX/nullptr_t-init.cpp
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Analysis/nullptr.cpp
cfe/trunk/test/SemaCXX/ast-print-crash.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=349206&r1=349205&r2=349206&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Dec 14 14:41:18 2018
@@ -4881,13 +4881,6 @@ static void TryDefaultInitialization(Sem
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
Modified: cfe/trunk/test/Analysis/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullptr.cpp?rev=349206&r1=349205&r2=349206&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nullptr.cpp (original)
+++ cfe/trunk/test/Analysis/nullptr.cpp Fri Dec 14 14:41:18 2018
@@ -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 at -1{{Taking false branch}}
- // expected-note at -2{{Assuming the condition is true}}
- // expected-note at -3{{Taking true branch}}
- invokeF(p); // expected-note{{Passing null pointer value via 1st parameter 'x'}}
- // expected-note at -1{{Calling 'invokeF'}}
+ // expected-note at -2{{Assuming the condition is false}}
+ // expected-note at -3{{Taking false branch}}
+ // expected-note at -4{{Assuming the condition is true}}
+ // expected-note at -5{{Taking true branch}}
+ invokeF(p); // expected-warning{{1st function call argument is an uninitialized value}}
+ // expected-note at -1{{1st function call argument is an uninitialized value}}
if (getSymbol()) // expected-note {{Assuming the condition is false}}
// expected-note at -1{{Taking false branch}}
- invokeF(nullptr);
+ // expected-note at -2{{Assuming the condition is true}}
+ // expected-note at -3{{Taking true branch}}
+ invokeF(nullptr); // expected-note {{Calling 'invokeF'}}
+ // expected-note at -1{{Passing null pointer value via 1st parameter 'x'}}
if (getSymbol()) { // expected-note {{Assuming the condition is true}}
// expected-note at -1{{Taking true branch}}
X *xx = Type().x; // expected-note {{Null pointer value stored to field 'x'}}
Modified: cfe/trunk/test/SemaCXX/ast-print-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print-crash.cpp?rev=349206&r1=349205&r2=349206&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print-crash.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print-crash.cpp Fri Dec 14 14:41:18 2018
@@ -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;
Removed: cfe/trunk/test/SemaCXX/nullptr_t-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nullptr_t-init.cpp?rev=349205&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/nullptr_t-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/nullptr_t-init.cpp (removed)
@@ -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;
-}
More information about the cfe-commits
mailing list