@@ -6502,6 +6502,22 @@ void InitializationSequence::InitializeFrom(Sema &S,
65026502 return ;
65036503 }
65046504
6505+ // Check if the cast is a C-style or functional cast.
6506+ bool IsCStyleCast = Kind.isCStyleOrFunctionalCast ();
6507+
6508+ // Update `IsCStyleCast` to true if all of the following conditions are met:
6509+ // - The string representations of the source and destination types are
6510+ // different.
6511+ // - The source type is a pointer and is volatile-qualified.
6512+ // - The destination type is not a pointer and is not volatile-qualified.
6513+ // This checks for a specific scenario where a C-style cast might be necessary
6514+ // to convert between these specific types under these conditions.
6515+ if (isa<PointerType>(SourceType) && !isa<PointerType>(DestType) &&
6516+ SourceType.getAsString () != DestType.getAsString () &&
6517+ SourceType.getAsString ().find (" volatile" ) != std::string::npos &&
6518+ DestType.getAsString ().find (" volatile" ) == std::string::npos)
6519+ IsCStyleCast = true ;
6520+
65056521 // - Otherwise, the initial value of the object being initialized is the
65066522 // (possibly converted) value of the initializer expression. Standard
65076523 // conversions (Clause 4) will be used, if necessary, to convert the
@@ -6513,7 +6529,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
65136529 /* SuppressUserConversions*/ true ,
65146530 Sema::AllowedExplicit::None,
65156531 /* InOverloadResolution*/ false ,
6516- /* CStyle=*/ Kind. isCStyleOrFunctionalCast () ,
6532+ /* CStyle=*/ IsCStyleCast ,
65176533 allowObjCWritebackConversion);
65186534
65196535 if (ICS.isStandard () &&
0 commit comments