Skip to content

Commit b24aed9

Browse files
committed
enable array by value assignment
1 parent b89bb77 commit b24aed9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

clang/include/clang/AST/CanonicalType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class CanProxyBase {
299299
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isDependentType)
300300
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isOverloadableType)
301301
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isArrayType)
302+
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isConstantArrayType)
302303
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasPointerRepresentation)
303304
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasObjCPointerRepresentation)
304305
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasIntegerRepresentation)

clang/lib/AST/ExprClassification.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
704704
return Cl::CM_ConstAddrSpace;
705705

706706
// Arrays are not modifiable, only their elements are.
707-
if (CT->isArrayType())
707+
if (CT->isArrayType() &&
708+
!(Ctx.getLangOpts().HLSL && CT->isConstantArrayType()))
708709
return Cl::CM_ArrayType;
709710
// Incomplete types are not modifiable.
710711
if (CT->isIncompleteType())

clang/lib/Sema/SemaOverload.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,16 +2232,21 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
22322232
// just strip the qualifiers because they don't matter.
22332233
FromType = FromType.getUnqualifiedType();
22342234
} else if (S.getLangOpts().HLSL && FromType->isConstantArrayType() &&
2235-
ToType->isArrayParameterType()) {
2235+
ToType->isConstantArrayType()) {
22362236
// HLSL constant array parameters do not decay, so if the argument is a
22372237
// constant array and the parameter is an ArrayParameterType we have special
22382238
// handling here.
2239-
FromType = S.Context.getArrayParameterType(FromType);
2239+
if (ToType->isArrayParameterType()) {
2240+
FromType = S.Context.getArrayParameterType(FromType);
2241+
SCS.First = ICK_HLSL_Array_RValue;
2242+
} else {
2243+
SCS.First = ICK_Identity;
2244+
}
2245+
22402246
if (S.Context.getCanonicalType(FromType) !=
22412247
S.Context.getCanonicalType(ToType))
22422248
return false;
22432249

2244-
SCS.First = ICK_HLSL_Array_RValue;
22452250
SCS.setAllToTypes(ToType);
22462251
return true;
22472252
} else if (FromType->isArrayType()) {

0 commit comments

Comments
 (0)