@@ -2236,33 +2236,24 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
22362236 return false;
22372237 }
22382238 }
2239- // Lvalue-to-rvalue conversion (C++11 4.1):
2240- // A glvalue (3.10) of a non-function, non-array type T can
2241- // be converted to a prvalue.
2242- bool argIsLValue = From->isGLValue();
2243- if (argIsLValue && !FromType->canDecayToPointerType() &&
2244- S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
2245- SCS.First = ICK_Lvalue_To_Rvalue;
2246-
2247- // C11 6.3.2.1p2:
2248- // ... if the lvalue has atomic type, the value has the non-atomic version
2249- // of the type of the lvalue ...
2250- if (const AtomicType *Atomic = FromType->getAs<AtomicType>())
2251- FromType = Atomic->getValueType();
22522239
2253- // If T is a non-class type, the type of the rvalue is the
2254- // cv-unqualified version of T. Otherwise, the type of the rvalue
2255- // is T (C++ 4.1p1). C++ can't get here with class types; in C, we
2256- // just strip the qualifiers because they don't matter.
2257- FromType = FromType.getUnqualifiedType();
2258- } else if (S.getLangOpts().HLSL && FromType->isConstantArrayType() &&
2259- ToType->isConstantArrayType()) {
2240+ bool argIsLValue = From->isGLValue();
2241+ // To handle conversion from ArrayParameterType to ConstantArrayType
2242+ // this block must be above the one below because Array parameters
2243+ // do not decay and when handling HLSLOutArgExprs and
2244+ // the From expression is an LValue.
2245+ if (S.getLangOpts().HLSL && FromType->isConstantArrayType() &&
2246+ ToType->isConstantArrayType()) {
22602247 // HLSL constant array parameters do not decay, so if the argument is a
22612248 // constant array and the parameter is an ArrayParameterType we have special
22622249 // handling here.
22632250 if (ToType->isArrayParameterType()) {
22642251 FromType = S.Context.getArrayParameterType(FromType);
22652252 SCS.First = ICK_HLSL_Array_RValue;
2253+ } else if (FromType->isArrayParameterType()) {
2254+ const ArrayParameterType *APT = cast<ArrayParameterType>(FromType);
2255+ FromType = APT->getConstantArrayType(S.Context);
2256+ SCS.First = ICK_HLSL_Array_RValue;
22662257 } else {
22672258 SCS.First = ICK_Identity;
22682259 }
@@ -2273,6 +2264,25 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
22732264
22742265 SCS.setAllToTypes(ToType);
22752266 return true;
2267+ } else if (argIsLValue && !FromType->canDecayToPointerType() &&
2268+ S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
2269+ // Lvalue-to-rvalue conversion (C++11 4.1):
2270+ // A glvalue (3.10) of a non-function, non-array type T can
2271+ // be converted to a prvalue.
2272+
2273+ SCS.First = ICK_Lvalue_To_Rvalue;
2274+
2275+ // C11 6.3.2.1p2:
2276+ // ... if the lvalue has atomic type, the value has the non-atomic version
2277+ // of the type of the lvalue ...
2278+ if (const AtomicType *Atomic = FromType->getAs<AtomicType>())
2279+ FromType = Atomic->getValueType();
2280+
2281+ // If T is a non-class type, the type of the rvalue is the
2282+ // cv-unqualified version of T. Otherwise, the type of the rvalue
2283+ // is T (C++ 4.1p1). C++ can't get here with class types; in C, we
2284+ // just strip the qualifiers because they don't matter.
2285+ FromType = FromType.getUnqualifiedType();
22762286 } else if (FromType->isArrayType()) {
22772287 // Array-to-pointer conversion (C++ 4.2)
22782288 SCS.First = ICK_Array_To_Pointer;
0 commit comments