Skip to content

Commit 1f5f4b4

Browse files
committed
respond to pr comments
1 parent 40676e4 commit 1f5f4b4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,6 +4286,7 @@ bool SemaHLSL::transformInitList(const InitializedEntity &Entity,
42864286
size_t ActualSize = ILT.ArgExprs.size();
42874287
if (ExpectedSize == 0 && ActualSize == 0)
42884288
return true;
4289+
42894290
// For incomplete arrays it is completely arbitrary to choose whether we think
42904291
// the user intended fewer or more elements. This implementation assumes that
42914292
// the user intended more, and errors that there are too few initializers to

clang/test/CodeGenHLSL/BasicFeatures/InitLists.hlsl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ struct UnnamedOnly {
5757
int : 8;
5858
};
5959

60+
struct EmptyDerived : Empty {};
61+
62+
struct UnnamedDerived : UnnamedOnly {};
63+
6064
// CHECK-DAG: [[ConstE:@.*]] = private unnamed_addr constant %struct.Empty undef, align 1
6165
// CHECK-DAG: [[ConstUO:@.*]] = private unnamed_addr constant %struct.UnnamedOnly undef, align 1
66+
// CHECK-DAG: [[ConstED:@.*]] = private unnamed_addr constant %struct.EmptyDerived undef, align 1
67+
// CHECK-DAG: [[ConstUD:@.*]] = private unnamed_addr constant %struct.UnnamedDerived undef, align 1
6268

6369
// Case 1: Extraneous braces get ignored in literal instantiation.
6470
// CHECK-LABEL: define hidden void @_Z5case1v(
@@ -1027,3 +1033,25 @@ void case22() {
10271033
void case23(UnnamedOnly UO) {
10281034
TwoInts TI = {UO, 1, 2};
10291035
}
1036+
1037+
// InitList with Derived empty struct on LHS
1038+
// InitList with Derived unnamed bitfield on LHS
1039+
// CHECK-LABEL: case24
1040+
// CHECK: [[ED:%.*]] = alloca %struct.EmptyDerived, align 1
1041+
// CHECK-NEXT: [[UD:%.*]] = alloca %struct.UnnamedDerived, align 1
1042+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 1 %ED, ptr align 1 [[ConstED]], i32 1, i1 false)
1043+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 1 %UD, ptr align 1 [[ConstUD]], i32 1, i1 false)
1044+
void case24() {
1045+
EmptyDerived ED = {};
1046+
UnnamedDerived UD = {};
1047+
}
1048+
1049+
// CHECK-LABEL: case25
1050+
// CHECK: [[TI1:%.*]] = alloca %struct.TwoInts, align 1
1051+
// CHECK-NEXT: [[TI2:%.*]] = alloca %struct.TwoInts, align 1
1052+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 1 %TI1, ptr align 1 {{.*}}, i32 8, i1 false)
1053+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 1 %TI2, ptr align 1 {{.*}}, i32 8, i1 false)
1054+
void case25(EmptyDerived ED, UnnamedDerived UD) {
1055+
TwoInts TI1 = {ED, 1, 2};
1056+
TwoInts TI2 = {UD, 1, 2};
1057+
}

0 commit comments

Comments
 (0)