@@ -6502,6 +6502,22 @@ void InitializationSequence::InitializeFrom(Sema &S,
6502
6502
return ;
6503
6503
}
6504
6504
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
+
6505
6521
// - Otherwise, the initial value of the object being initialized is the
6506
6522
// (possibly converted) value of the initializer expression. Standard
6507
6523
// conversions (Clause 4) will be used, if necessary, to convert the
@@ -6513,7 +6529,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
6513
6529
/* SuppressUserConversions*/ true ,
6514
6530
Sema::AllowedExplicit::None,
6515
6531
/* InOverloadResolution*/ false ,
6516
- /* CStyle=*/ Kind. isCStyleOrFunctionalCast () ,
6532
+ /* CStyle=*/ IsCStyleCast ,
6517
6533
allowObjCWritebackConversion);
6518
6534
6519
6535
if (ICS.isStandard () &&
0 commit comments