Skip to content

Commit 975e1e3

Browse files
committed
fix bug + test
1 parent aa500a7 commit 975e1e3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,7 +3902,8 @@ QualType ASTContext::getArrayParameterType(QualType Ty) const {
39023902
if (Ty->isArrayParameterType())
39033903
return Ty;
39043904
assert(Ty->isConstantArrayType() && "Ty must be an array type.");
3905-
const auto *ATy = cast<ConstantArrayType>(Ty.getDesugaredType(*this));
3905+
QualType DTy = Ty.getDesugaredType(*this);
3906+
const auto *ATy = cast<ConstantArrayType>(DTy);
39063907
llvm::FoldingSetNodeID ID;
39073908
ATy->Profile(ID, *this, ATy->getElementType(), ATy->getZExtSize(),
39083909
ATy->getSizeExpr(), ATy->getSizeModifier(),
@@ -3914,7 +3915,7 @@ QualType ASTContext::getArrayParameterType(QualType Ty) const {
39143915
return QualType(AT, 0);
39153916

39163917
QualType Canonical;
3917-
if (!Ty.isCanonical()) {
3918+
if (!DTy.isCanonical()) {
39183919
Canonical = getArrayParameterType(getCanonicalType(Ty));
39193920

39203921
// Get the new insert position for the node we care about.

clang/test/AST/HLSL/TypdefArrayParam.hlsl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ void call2() {
5555
uint4 C[2] = {A,A};
5656
uint32_t D = Accumulate(C);
5757
}
58+
59+
typedef int Foo[2];
60+
61+
// CHECK-LABEL: call3
62+
// CHECK: ArraySubscriptExpr {{.*}} 'int' lvalue
63+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <ArrayToPointerDecay>
64+
// CHECK-NEXT: DeclRefExpr {{.*}} 'int[2]' lvalue ParmVar {{.*}} 'F' 'int[2]'
65+
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0
66+
int call3(Foo F) {
67+
return F[0];
68+
}

0 commit comments

Comments
 (0)