MitalAshok updated this revision to Diff 536648. MitalAshok edited the summary of this revision. MitalAshok added a comment.
Add status for CWG2681 and fixed aggregate-deduction-candidate test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154301/new/ https://reviews.llvm.org/D154301 Files: clang/lib/Sema/SemaInit.cpp clang/test/CXX/drs/dr26xx.cpp clang/test/SemaTemplate/aggregate-deduction-candidate.cpp clang/www/cxx_dr_status.html Index: clang/www/cxx_dr_status.html =================================================================== --- clang/www/cxx_dr_status.html +++ clang/www/cxx_dr_status.html @@ -15893,7 +15893,7 @@ <td><a href="https://cplusplus.github.io/CWG/issues/2681.html">2681</a></td> <td>DR</td> <td>Deducing member array type from string literal</td> - <td class="none" align="center">Unknown</td> + <td class="unreleased" align="center">Clang 17</td> </tr> <tr id="2682"> <td><a href="https://cplusplus.github.io/CWG/issues/2682.html">2682</a></td> Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp =================================================================== --- clang/test/SemaTemplate/aggregate-deduction-candidate.cpp +++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp @@ -198,22 +198,22 @@ // CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for A> // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned {{.*}}' depth 0 index 1 N - // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for A> 'auto (T (&)[N]) -> A<T, N>' - // CHECK: | `-ParmVarDecl {{.*}} 'T (&)[N]' - // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (const char (&)[5]) -> Array::A<const char, 5>' - // CHECK: |-TemplateArgument type 'const char' - // CHECK: | `-QualType {{.*}} 'const char' const - // CHECK: | `-BuiltinType {{.*}} 'char' + // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for A> 'auto (const T (&)[N]) -> A<T, N>' + // CHECK: | `-ParmVarDecl {{.*}} 'const T (&)[N]' + // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (const char (&)[5]) -> Array::A<char, 5>' + // CHECK: |-TemplateArgument type 'char' + // CHECK: | `-BuiltinType {{.*}} 'char' // CHECK: |-TemplateArgument integral 5 // CHECK: `-ParmVarDecl {{.*}} 'const char (&)[5]' - // CHECK: FunctionProtoType {{.*}} 'auto (T (&)[N]) -> A<T, N>' dependent trailing_return cdecl + // CHECK: FunctionProtoType {{.*}} 'auto (const T (&)[N]) -> A<T, N>' dependent trailing_return cdecl // CHECK: |-InjectedClassNameType {{.*}} 'A<T, N>' dependent // CHECK: | `-CXXRecord {{.*}} 'A' - // CHECK: `-LValueReferenceType {{.*}} 'T (&)[N]' dependent - // CHECK: `-DependentSizedArrayType {{.*}} 'T[N]' dependent - // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 - // CHECK: | `-TemplateTypeParm {{.*}} 'T' - // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned {{.*}}' NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned {{.*}}' + // CHECK: `-LValueReferenceType {{.*}} 'const T (&)[N]' dependent + // CHECK: `-QualType {{.*}} 'const T[N]' const + // CHECK: `-DependentSizedArrayType {{.*}} 'T[N]' dependent + // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: | `-TemplateTypeParm {{.*}} 'T' + // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned{{.*}}' NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned{{.*}}' } namespace BraceElision { Index: clang/test/CXX/drs/dr26xx.cpp =================================================================== --- clang/test/CXX/drs/dr26xx.cpp +++ clang/test/CXX/drs/dr26xx.cpp @@ -126,3 +126,27 @@ brachiosaur |= neck; // OK } } + +namespace dr2681 { // dr2681: 17 +using size_t = decltype(sizeof(int)); + +template<class T, size_t N> +struct H { + T array[N]; +}; +template<class T, size_t N> +struct I { + volatile T array[N]; +}; +template<size_t N> +struct J { // expected-note 3{{candidate}} + unsigned char array[N]; +}; + +H h = { "abc" }; +I i = { "def" }; +static_assert(__is_same(decltype(h), H<char, 4>)); // Not H<const char, 4> +static_assert(__is_same(decltype(i), I<char, 4>)); + +J j = { "ghi" }; // expected-error {{no viable constructor or deduction guide}} +} Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -10714,7 +10714,8 @@ ElementTypes[I] = Context.getRValueReferenceType(ElementTypes[I]); else if (isa<StringLiteral>( ListInit->getInit(I)->IgnoreParenImpCasts())) - ElementTypes[I] = Context.getLValueReferenceType(ElementTypes[I]); + ElementTypes[I] = + Context.getLValueReferenceType(ElementTypes[I].withConst()); } llvm::FoldingSetNodeID ID;
Index: clang/www/cxx_dr_status.html =================================================================== --- clang/www/cxx_dr_status.html +++ clang/www/cxx_dr_status.html @@ -15893,7 +15893,7 @@ <td><a href="https://cplusplus.github.io/CWG/issues/2681.html">2681</a></td> <td>DR</td> <td>Deducing member array type from string literal</td> - <td class="none" align="center">Unknown</td> + <td class="unreleased" align="center">Clang 17</td> </tr> <tr id="2682"> <td><a href="https://cplusplus.github.io/CWG/issues/2682.html">2682</a></td> Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp =================================================================== --- clang/test/SemaTemplate/aggregate-deduction-candidate.cpp +++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp @@ -198,22 +198,22 @@ // CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for A> // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned {{.*}}' depth 0 index 1 N - // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for A> 'auto (T (&)[N]) -> A<T, N>' - // CHECK: | `-ParmVarDecl {{.*}} 'T (&)[N]' - // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (const char (&)[5]) -> Array::A<const char, 5>' - // CHECK: |-TemplateArgument type 'const char' - // CHECK: | `-QualType {{.*}} 'const char' const - // CHECK: | `-BuiltinType {{.*}} 'char' + // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for A> 'auto (const T (&)[N]) -> A<T, N>' + // CHECK: | `-ParmVarDecl {{.*}} 'const T (&)[N]' + // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (const char (&)[5]) -> Array::A<char, 5>' + // CHECK: |-TemplateArgument type 'char' + // CHECK: | `-BuiltinType {{.*}} 'char' // CHECK: |-TemplateArgument integral 5 // CHECK: `-ParmVarDecl {{.*}} 'const char (&)[5]' - // CHECK: FunctionProtoType {{.*}} 'auto (T (&)[N]) -> A<T, N>' dependent trailing_return cdecl + // CHECK: FunctionProtoType {{.*}} 'auto (const T (&)[N]) -> A<T, N>' dependent trailing_return cdecl // CHECK: |-InjectedClassNameType {{.*}} 'A<T, N>' dependent // CHECK: | `-CXXRecord {{.*}} 'A' - // CHECK: `-LValueReferenceType {{.*}} 'T (&)[N]' dependent - // CHECK: `-DependentSizedArrayType {{.*}} 'T[N]' dependent - // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 - // CHECK: | `-TemplateTypeParm {{.*}} 'T' - // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned {{.*}}' NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned {{.*}}' + // CHECK: `-LValueReferenceType {{.*}} 'const T (&)[N]' dependent + // CHECK: `-QualType {{.*}} 'const T[N]' const + // CHECK: `-DependentSizedArrayType {{.*}} 'T[N]' dependent + // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: | `-TemplateTypeParm {{.*}} 'T' + // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned{{.*}}' NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned{{.*}}' } namespace BraceElision { Index: clang/test/CXX/drs/dr26xx.cpp =================================================================== --- clang/test/CXX/drs/dr26xx.cpp +++ clang/test/CXX/drs/dr26xx.cpp @@ -126,3 +126,27 @@ brachiosaur |= neck; // OK } } + +namespace dr2681 { // dr2681: 17 +using size_t = decltype(sizeof(int)); + +template<class T, size_t N> +struct H { + T array[N]; +}; +template<class T, size_t N> +struct I { + volatile T array[N]; +}; +template<size_t N> +struct J { // expected-note 3{{candidate}} + unsigned char array[N]; +}; + +H h = { "abc" }; +I i = { "def" }; +static_assert(__is_same(decltype(h), H<char, 4>)); // Not H<const char, 4> +static_assert(__is_same(decltype(i), I<char, 4>)); + +J j = { "ghi" }; // expected-error {{no viable constructor or deduction guide}} +} Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -10714,7 +10714,8 @@ ElementTypes[I] = Context.getRValueReferenceType(ElementTypes[I]); else if (isa<StringLiteral>( ListInit->getInit(I)->IgnoreParenImpCasts())) - ElementTypes[I] = Context.getLValueReferenceType(ElementTypes[I]); + ElementTypes[I] = + Context.getLValueReferenceType(ElementTypes[I].withConst()); } llvm::FoldingSetNodeID ID;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits