diff options
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/alias-template.cpp | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 61bd1077941..ba4bcbc488c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2759,9 +2759,10 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, QualType canon = getQualifiedType(QualType(canonTy,0), canonElementType.Quals); - // If we didn't need extra canonicalization for the element type, - // then just use that as our result. - if (QualType(canonElementType.Ty, 0) == elementType) + // If we didn't need extra canonicalization for the element type or the size + // expression, then just use that as our result. + if (QualType(canonElementType.Ty, 0) == elementType && + canonTy->getSizeExpr() == numElements) return canon; // Otherwise, we need to build a type which follows the spelling diff --git a/clang/test/SemaCXX/alias-template.cpp b/clang/test/SemaCXX/alias-template.cpp index d5eb27a6613..bcfe428c69d 100644 --- a/clang/test/SemaCXX/alias-template.cpp +++ b/clang/test/SemaCXX/alias-template.cpp @@ -168,3 +168,14 @@ namespace SFINAE { fail1<int> f1; // expected-note {{here}} fail2<E> f2; // expected-note {{here}} } + +namespace PR24212 { +struct X {}; +template <int I> +struct S { + template <int J> + using T = X[J]; + using U = T<I>; +}; +static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static_assert failed}} +} |