diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -6336,6 +6336,7 @@ // We're at the end of the line for C: it's either a write-back conversion // or it's a C assignment. There's no need to check anything else. if (!S.getLangOpts().CPlusPlus) { + assert(Initializer && "Initializer must be non-null"); // If allowed, check whether this is an Objective-C writeback conversion. if (allowObjCWritebackConversion && tryObjCWritebackConversion(S, *this, Entity, Initializer)) { @@ -6362,7 +6363,8 @@ if (Kind.getKind() == InitializationKind::IK_Direct || (Kind.getKind() == InitializationKind::IK_Copy && (Context.hasSameUnqualifiedType(SourceType, DestType) || - S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType)))) { + (Initializer && S.IsDerivedFrom(Initializer->getBeginLoc(), + SourceType, DestType))))) { TryConstructorInitialization(S, Entity, Kind, Args, DestType, DestType, *this); @@ -6406,6 +6408,7 @@ // function is used) to a derived class thereof are enumerated as // described in 13.3.1.4, and the best one is chosen through // overload resolution (13.3). + assert(Initializer && "Initializer must be non-null"); TryUserDefinedConversion(S, DestType, Kind, Initializer, *this, TopLevelOfInitList); } @@ -6457,6 +6460,7 @@ // - Otherwise, if the source type is a (possibly cv-qualified) class // type, conversion functions are considered. if (!SourceType.isNull() && SourceType->isRecordType()) { + assert(Initializer && "Initializer must be non-null"); // For a conversion to _Atomic(T) from either T or a class type derived // from T, initialize the T object then convert to _Atomic type. bool NeedAtomicConversion = false;